/* ============================================================
   MaintainEzy Admin Portal - Stylesheet
   ============================================================ */

:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --primary-light: #eef1ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    --info: #06b6d4;
    --info-light: #cffafe;
    --sidebar-text: #cbd5e1;
    --sidebar-active-bg: rgba(67, 97, 238, 0.15);
    --sidebar-active-text: #4361ee;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --topbar-bg: #ffffff;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.layout-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 250px;
    min-height: 100vh;
}

.content-area {
    padding: 24px 28px;
    flex: 1;
}

.loading-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #1e2a4a 0%, #16213e 100%);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-nav {
    list-style: none;
    padding: 8px 0;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    margin: 2px 10px;
    color: #cbd5e1;
    text-decoration: none !important;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:link,
.sidebar-nav li a:visited {
    color: #cbd5e1;
    text-decoration: none !important;
}

.sidebar-nav li a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar-nav li a.active {
    background: rgba(67, 97, 238, 0.15);
    color: #4361ee;
    font-weight: 600;
}

.sidebar-nav li a.active .nav-icon {
    color: #4361ee;
    opacity: 1;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav li a:hover .nav-icon {
    opacity: 1;
}

.nav-text {
    white-space: nowrap;
}

.nav-section {
    padding: 20px 18px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #64748b;
    font-weight: 700;
}

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    line-height: 1.2;
}

.user-role-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
}

.btn-logout:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* ============================================================
   DASHBOARD - STAT CARDS (Top Row)
   ============================================================ */

.dash-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-card-header {
    padding: 16px 20px 0;
}

.stat-card-body {
    padding: 4px 20px 20px;
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.3;
}

.stat-card.card-blue {
    border-top: 4px solid #4361ee;
}

.stat-card.card-blue .stat-value {
    color: #4361ee;
}

.stat-card.card-green {
    border-top: 4px solid #10b981;
}

.stat-card.card-green .stat-value {
    color: #10b981;
}

.stat-card.card-purple {
    border-top: 4px solid #8b5cf6;
}

.stat-card.card-purple .stat-value {
    color: #8b5cf6;
}

.stat-card.card-orange {
    border-top: 4px solid #f59e0b;
}

.stat-card.card-orange .stat-value {
    color: #f59e0b;
}

.stat-card.card-red {
    border-top: 4px solid #ef4444;
}

.stat-card.card-red .stat-value {
    color: #ef4444;
}

.stat-card.card-teal {
    border-top: 4px solid #06b6d4;
}

.stat-card.card-teal .stat-value {
    color: #06b6d4;
}

/* ============================================================
   DASHBOARD - PANEL CARDS (Middle Row)
   ============================================================ */

.dash-panels-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.panel-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.panel-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.panel-card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}

.panel-action-link {
    font-size: 0.78rem;
    color: #4361ee;
    text-decoration: none;
    font-weight: 600;
}

.panel-action-link:hover {
    text-decoration: underline;
}

.panel-card-body {
    padding: 16px 20px;
}

/* Overview list */
.overview-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.overview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.overview-label {
    font-size: 0.85rem;
    color: #64748b;
}

.overview-value {
    font-size: 1rem;
    font-weight: 700;
}

.text-green {
    color: #10b981;
}

.text-orange {
    color: #f59e0b;
}

.text-red {
    color: #ef4444;
}

.text-blue {
    color: #4361ee;
}

.text-purple {
    color: #8b5cf6;
}

/* Breakdown bar chart */
.breakdown-chart {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.breakdown-bar {
    display: flex;
    height: 14px;
    border-radius: 7px;
    overflow: hidden;
    background: #f1f5f9;
}

.bar-segment {
    height: 100%;
    min-width: 4px;
}

.bar-green {
    background: #10b981;
}

.bar-orange {
    background: #f59e0b;
}

.bar-red {
    background: #ef4444;
}

.bar-blue {
    background: #4361ee;
}

.bar-gray {
    background: #cbd5e1;
}

.breakdown-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #64748b;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-green {
    background: #10b981;
}

.dot-orange {
    background: #f59e0b;
}

.dot-red {
    background: #ef4444;
}

.dot-blue {
    background: #4361ee;
}

.dot-gray {
    background: #cbd5e1;
}

/* Summary stats inside panel */
.summary-stats {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.summary-stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.summary-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.summary-stat-icon.icon-blue {
    background: #eef1ff;
    color: #4361ee;
}

.summary-stat-icon.icon-green {
    background: #d1fae5;
    color: #10b981;
}

.summary-stat-icon.icon-purple {
    background: #ede9fe;
    color: #8b5cf6;
}

.summary-stat-icon.icon-orange {
    background: #fef3c7;
    color: #f59e0b;
}

.summary-stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.summary-stat-label {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* ============================================================
   DASHBOARD - QUICK ACTIONS (Bottom Row)
   ============================================================ */

.dash-actions-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    color: #1e293b !important;
    text-decoration: none !important;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.quick-action-btn:link,
.quick-action-btn:visited {
    color: #1e293b !important;
    text-decoration: none !important;
}

.quick-action-btn:hover {
    background: #4361ee;
    color: #fff !important;
    border-color: #4361ee;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* ============================================================
   DASHBOARD LOADING
   ============================================================ */

.dashboard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
    color: #94a3b8;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: #4361ee;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn:hover {
    background: #f0f2f5;
}

.btn-primary {
    background: #4361ee;
    color: white;
    border-color: #4361ee;
}

.btn-primary:hover {
    background: #3a56d4;
}

.btn-danger {
    background: transparent;
    color: #ef4444;
    border-color: #ef4444;
}

.btn-danger:hover {
    background: #ef4444;
    color: white;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    background: #f0f2f5;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    border-bottom: 2px solid #e2e8f0;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.875rem;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

/* ============================================================
   STATUS BADGES
   ============================================================ */

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-active,
.status-completed,
.status-paid,
.status-approved,
.status-bookable {
    background: #d1fae5;
    color: #065f46;
}

.status-inactive,
.status-cancelled,
.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.status-pending,
.status-draft,
.status-trial {
    background: #fef3c7;
    color: #92400e;
}

.status-open,
.status-medium {
    background: #dbeafe;
    color: #1e40af;
}

.status-open-for-booking {
    background: #d1fae5;
    color: #065f46;
}

.status-closed-(maintenance),
.status-closed-maintenance {
    background: #fef3c7;
    color: #92400e;
}

.status-fully-booked {
    background: #fee2e2;
    color: #991b1b;
}

.status-confirmed {
    background: #d1fae5;
    color: #065f46;
}

.status-in-progress,
.status-partially-paid,
.status-in_progress {
    background: #ede9fe;
    color: #5b21b6;
}

.status-overdue,
.status-high,
.status-critical,
.status-expired {
    background: #fee2e2;
    color: #991b1b;
}

.status-resolved,
.status-closed {
    background: #d1fae5;
    color: #065f46;
}

.status-low {
    background: #f0fdf4;
    color: #166534;
}

.status-occupied {
    background: #dbeafe;
    color: #1e40af;
}

.status-vacant {
    background: #f0fdf4;
    color: #166534;
}

.status-not-bookable {
    background: #fee2e2;
    color: #991b1b;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #4361ee;
    color: white;
}

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.empty-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2a4a 0%, #16213e 50%, #0f172a 100%);
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #4361ee;
    margin-bottom: 4px;
}

.login-header p {
    color: #94a3b8;
    font-size: 0.875rem;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: #4361ee;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.btn-login:hover:not(:disabled) {
    background: #3a56d4;
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ============================================================
   LEGACY (other pages using dashboard-grid)
   ============================================================ */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.dashboard-section {
    margin-bottom: 24px;
}

.dashboard-section h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}

.form-control:disabled {
    background: #f8fafc;
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: auto;
}

textarea.form-control {
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   MODAL OVERLAY & DIALOG
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.15s ease-out;
}

.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 28px 32px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    animation: scaleIn 0.2s ease-out;
}

.modal h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1200px) {
    .dash-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-panels-row {
        grid-template-columns: 1fr;
    }

    .dash-actions-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.9rem;
}

/* ============================================================
   SEARCH BOX
   ============================================================ */

.search-box {
    flex: 1;
    max-width: 320px;
}

.search-box .form-control {
    max-width: 100%;
}

/* ============================================================
   FORM ROW (side-by-side fields)
   ============================================================ */

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

/* ============================================================
   CARD (generic)
   ============================================================ */

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-body {
    padding: 20px;
}

.mb-4 {
    margin-bottom: 24px;
}

/* ============================================================
   OUTLINE BUTTON
   ============================================================ */

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================================
   TOAST ANIMATION
   ============================================================ */

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .logo-text,
    .nav-text,
    .nav-section {
        display: none;
    }

    .sidebar-nav li a {
        justify-content: center;
        padding: 12px;
        margin: 2px 6px;
    }

    .main-content {
        margin-left: 60px;
    }

    .dash-stats-row {
        grid-template-columns: 1fr;
    }

    .dash-actions-row {
        grid-template-columns: 1fr;
    }

    .content-area {
        padding: 16px;
    }
}
