/* ============================================================
   Advance Realty – Work Order Dashboard
   Design: Dark navy corporate palette, clean modern layout
   ============================================================ */

:root {
    --navy-900: #0D1B2A;
    --navy-800: #1B2838;
    --navy-700: #1B3A5C;
    --navy-600: #234B73;
    --navy-500: #2E6096;
    --slate-100: #F1F5F9;
    --slate-200: #E2E8F0;
    --slate-300: #CBD5E1;
    --slate-400: #94A3B8;
    --slate-500: #64748B;
    --slate-600: #475569;
    --white: #FFFFFF;
    --accent-green: #10B981;
    --accent-orange: #F59E0B;
    --accent-red: #EF4444;
    --accent-blue: #3B82F6;
    --accent-purple: #8B5CF6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--slate-100);
    color: var(--navy-800);
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 100%);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px; height: 40px;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
}

.logo-icon svg { width: 22px; height: 22px; color: var(--accent-blue); }

.logo-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    display: block;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--slate-400);
    display: block;
    margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--slate-300);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active { background: rgba(59,130,246,0.2); color: var(--white); }
.nav-item svg { width: 18px; height: 18px; }

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--slate-400);
    margin-bottom: 8px;
}

.user-info svg { width: 16px; height: 16px; }

.logout-btn { font-size: 13px; }

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

.top-bar {
    background: var(--white);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--slate-200);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.menu-toggle svg { width: 22px; height: 22px; }

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--navy-800);
}

.top-bar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.content-area { padding: 28px 32px; }

/* ── Flash Messages ──────────────────────────────────────── */
.flash-messages { padding: 16px 32px 0; }

.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
    animation: slideDown 0.3s ease;
}

.flash svg { width: 18px; height: 18px; flex-shrink: 0; }

.flash-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.flash-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.flash-info { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

.flash-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition);
}

.flash-close:hover { opacity: 1; }
.flash-close svg { width: 16px; height: 16px; }

/* ── Report Selector ─────────────────────────────────────── */
.report-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.report-selector label {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.report-selector select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--white);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5L6 8L9 5' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* ── Dashboard Cards Grid ────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px 0;
}

.card-icon {
    width: 42px; height: 42px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.card-icon svg { width: 20px; height: 20px; color: var(--white); }

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-body { padding: 16px 20px 20px; }

.card-metric {
    font-size: 40px;
    font-weight: 800;
    color: var(--navy-800);
    line-height: 1.1;
}

.card-metric .unit {
    font-size: 16px;
    font-weight: 600;
    color: var(--slate-400);
    margin-left: 4px;
}

/* Wide cards for tables/charts */
.card-wide {
    grid-column: span 2;
}

.card-full {
    grid-column: 1 / -1;
}

/* ── Tables inside cards ─────────────────────────────────── */
.card-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.card-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--slate-500);
    border-bottom: 2px solid var(--slate-200);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--navy-800);
}

.card-table tr:last-child td { border-bottom: none; }
.card-table tr:hover td { background: var(--slate-100); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-days {
    background: #FEF3C7;
    color: #92400E;
}

.badge-days.critical {
    background: #FEE2E2;
    color: #991B1B;
}

/* ── Notes ───────────────────────────────────────────────── */
.note-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--slate-100);
}

.note-item:last-child { border-bottom: none; }

.note-header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 6px;
}

.note-wo {
    font-weight: 700;
    font-size: 13px;
    color: var(--navy-700);
}

.note-property {
    font-size: 12px;
    color: var(--slate-400);
}

.note-text {
    font-size: 13px;
    color: var(--slate-600);
    line-height: 1.5;
    max-height: 80px;
    overflow: hidden;
    position: relative;
}

.note-text.expanded { max-height: none; }

.note-toggle {
    background: none;
    border: none;
    color: var(--accent-blue);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 0;
    font-weight: 600;
}

/* ── Charts ──────────────────────────────────────────────── */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-600);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color var(--transition);
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5L6 8L9 5' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--navy-700);
    color: var(--white);
}
.btn-primary:hover { background: var(--navy-600); }

.btn-success {
    background: var(--accent-green);
    color: var(--white);
}
.btn-success:hover { background: #059669; }

.btn-danger {
    background: var(--accent-red);
    color: var(--white);
}
.btn-danger:hover { background: #DC2626; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--slate-300);
    color: var(--slate-600);
}
.btn-outline:hover { background: var(--slate-100); }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
}

/* ── Admin sections ──────────────────────────────────────── */
.admin-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    overflow: hidden;
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--slate-200);
}

.admin-section-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy-800);
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-section-header h2 svg { width: 20px; height: 20px; color: var(--navy-700); }

.admin-section-body { padding: 20px 24px; }

/* ── Upload area ─────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--slate-300);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
    background: var(--white);
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent-blue);
    background: #EFF6FF;
}

.upload-zone svg { width: 48px; height: 48px; color: var(--slate-400); margin-bottom: 16px; }
.upload-zone h3 { font-size: 16px; color: var(--navy-800); margin-bottom: 8px; }
.upload-zone p { font-size: 13px; color: var(--slate-400); }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 56px; height: 56px;
    margin: 0 auto 12px;
    background: var(--navy-700);
}

.login-logo h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--navy-800);
}

.login-logo p {
    font-size: 13px;
    color: var(--slate-400);
    margin-top: 4px;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--slate-200);
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--slate-200);
}

/* ── Misc ────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--slate-400);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; }
.empty-state h3 { color: var(--slate-500); font-size: 16px; margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.tag-admin { background: #DBEAFE; color: #1E40AF; }
.tag-viewer { background: #F3F4F6; color: #4B5563; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .cards-grid { grid-template-columns: 1fr; }
    .card-wide, .card-full { grid-column: span 1; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .content-area { padding: 16px; }
    .top-bar { padding: 12px 16px; }
    .card-metric { font-size: 32px; }
}
