:root {
    --bg-base: #0F172A; /* Luminous Deep Navy (Slate 900) */
    --surface: #1E293B; /* Elevated Navy Surface (Slate 800) */
    --surface-light: #334155; /* Accent Navy Card (Slate 700) */
    --text-main: #F8FAFC; /* Crisp White */
    --text-muted: #94A3B8; /* Slate gray readability */
    --gold: #F59E0B; /* Brilliant Amber Gold */
    --gold-glow: rgba(245, 158, 11, 0.15); /* Gold glow */
    --border: #334155; /* Smooth Navy Border */
    --success: #10B981;
    --danger: #EF4444;
    --radius-lg: 20px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    padding-bottom: 90px; /* for fixed bottom nav */
    overflow-x: hidden;
}

/* Base Utility */
h1, h2, h3, h4 {
    margin: 0;
    font-family: 'Playfair Display', serif;
}
p {
    margin: 0;
}
.highlight { color: var(--gold); }
.gold { color: var(--gold); }

/* Demo Role Switcher */
#demo-role-switcher {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px;
    text-align: center;
    position: relative;
    z-index: 1000;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    color: #FFFFFF;
}

#demo-role-switcher select {
    background: var(--surface-light);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: 6px;
    font-family: inherit;
    margin-left: 8px;
    outline: none;
}

/* Background for Customer */
.featured-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('https://images.unsplash.com/photo-1541888081120-7f2873138382?ixlib=rb-4.0.3&auto=format&fit=crop&w=2560&q=100');
    background-size: cover;
    background-position: center;
    z-index: -2;
    transition: opacity 0.5s ease;
    display: none; /* Only visible in customer view */
}

/* Show BG if body has .role-customer or .role-login */
body.role-customer .featured-bg,
body.role-login .featured-bg {
    display: block;
}

.bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Beautiful smooth fade from untouched bright sky down to the luminous deep navy */
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.0) 0%, rgba(15, 23, 42, 0.1) 25%, rgba(15, 23, 42, 0.8) 70%, rgba(15, 23, 42, 1) 100%);
    backdrop-filter: blur(2px);
    z-index: -1;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    position: relative;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: 2px;
    font-size: 1.2rem;
    color: var(--text-main);
    font-family: 'Playfair Display', serif;
}
.logo i { color: var(--gold); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-light);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
}

/* Views */
.view-section {
    display: none;
    padding: 0 24px;
    animation: fadeIn 0.4s ease;
}
.view-section.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-top: 10px;
}

/* Hero Section */
.hero-section {
    margin: 20px 0 30px;
    text-align: center;
}
.hero-section h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.forecast {
    display: inline-block;
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-main);
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 28px;
    border-radius: 30px;
    margin-bottom: 36px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.forecast .highlight {
    color: var(--gold);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.progress-container {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #9C8360 0%, var(--gold) 100%);
    border-radius: 4px;
    transition: width 1s ease-out;
}
.progress-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gold);
}

/* Cards */
.card {
    background: rgba(30, 41, 59, 0.7); /* Luminous Navy Glassmorphism */
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.08); /* Crisp highlight */
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

/* Blocker Alert */
.blocker-alert {
    display: flex;
    align-items: center;
    gap: 16px;
    border-left: 4px solid var(--danger);
    background: rgba(239, 68, 68, 0.05);
}
.blocker-alert .icon {
    font-size: 1.5rem;
    color: var(--danger);
}
.blocker-alert h4 { color: var(--text-main); margin-bottom: 4px;}
.blocker-alert p { color: var(--text-muted); font-size: 0.9rem; }

/* AI Predictive Alert Global Banner */
.ai-alert-banner {
    margin: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.05);
    animation: slideDownFade 0.6s ease;
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    margin-bottom: 0px;
}
.ai-alert-banner::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--gold);
    box-shadow: 0 0 12px var(--gold);
}
.ai-alert-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    color: var(--gold);
    font-weight: 600;
    letter-spacing: 1px;
}
.ai-pulse-icon {
    animation: aiPulseGlow 2s infinite;
}
@keyframes aiPulseGlow {
    0% { filter: drop-shadow(0 0 2px var(--gold)); opacity: 0.8; }
    50% { filter: drop-shadow(0 0 10px var(--gold)); opacity: 1; transform: scale(1.1); }
    100% { filter: drop-shadow(0 0 2px var(--gold)); opacity: 0.8; transform: scale(1); }
}
.ai-alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    transition: color 0.2s;
}
.ai-alert-close:hover { color: var(--text-main); }
.ai-alert-body {
    margin-left: 36px;
}
.ai-alert-body p {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 8px;
    color: var(--text-main);
}
.ai-danger-text { color: #EF4444; font-weight: 600; }
.ai-alert-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}
.btn-ai-action {
    background: var(--surface-light);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-ai-action:hover {
    background: var(--bg-base);
}
.btn-ai-action.primary {
    background: var(--gold-glow);
    border-color: var(--gold);
    color: var(--gold);
    font-weight: 600;
}
.btn-ai-action.primary:hover {
    background: var(--gold);
    color: #FFFFFF;
}

/* AI Generative Tooltip */
.ai-tooltip-container {
    position: relative;
    display: inline-block;
    cursor: pointer;
    color: var(--gold);
}
.ai-tooltip-container .ai-tooltip-content {
    visibility: hidden;
    width: 280px;
    background-color: var(--surface-light);
    color: var(--text-main);
    text-align: left;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    right: 0;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    line-height: 1.6;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    font-family: 'Plus Jakarta Sans', sans-serif;
}
.ai-tooltip-container:hover .ai-tooltip-content,
.ai-tooltip-container:active .ai-tooltip-content {
    visibility: visible;
    opacity: 1;
}
.ai-tooltip-content ol {
    margin: 8px 0 0 0;
    padding-left: 20px;
    color: var(--text-muted);
}
.ai-tooltip-content li {
    margin-bottom: 6px;
}

/* Live Badge Card */
.live-badge-card {
    display: flex;
    align-items: center;
    gap: 16px;
}
.live-pulse {
    width: 12px;
    height: 12px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Vault Access Cards */
.vault-access {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}
.vault-access .icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gold-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-size: 1.2rem;
}
.vault-access .info {
    flex: 1;
    margin-left: 16px;
}
.vault-access h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}
.vault-access p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Forms & Inputs */
.input-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.input-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.input-group input, .input-group textarea {
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.input-group input:focus, .input-group textarea:focus {
    border-color: var(--gold);
}

/* Role Based Visibility Overrides */
body:not(.role-admin) .admin-only {
    display: none !important;
}

.btn-primary {
    background: var(--gold);
    color: #000;
    border: none;
    border-radius: var(--radius-md);
    padding: 16px;
    width: 100%;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: opacity 0.2s;
}
.btn-primary:hover {
    opacity: 0.9;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 16px;
    cursor: pointer;
}
.upload-area i {
    font-size: 2rem;
    color: var(--gold);
    margin-bottom: 12px;
}

/* Finance Chart Area */
.finance-card {
    cursor: pointer;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.card-header h3 { font-size: 1.2rem; }
.card-header i { color: var(--gold); }
.chart-container {
    height: 200px;
    position: relative;
    margin-bottom: 16px;
}
.insight {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    background: var(--surface-light);
    padding: 10px;
    border-radius: 8px;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(20, 22, 28, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-around;
    padding: 16px 0 calc(16px + env(safe-area-inset-bottom));
    z-index: 100;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: color 0.2s;
}
.nav-item i {
    font-size: 1.2rem;
}
.nav-item.active {
    color: var(--gold);
}

/* Checklists & Lists */
.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
}
.checklist li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.checklist li:last-child {
    border-bottom: none;
}

/* Daily Feed */
.daily-feed h3 {
    margin-bottom: 16px;
}
.feed-item {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
}
.feed-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}
.feed-caption {
    padding: 16px 16px 4px;
    font-weight: 500;
}
.feed-date {
    padding: 0 16px 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    z-index: 200;
    align-items: flex-end;
}
.modal.show {
    display: flex;
}
.modal-content {
    background: var(--surface);
    width: 100%;
    border-radius: 24px 24px 0 0;
    padding: 24px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Financial Summary Inside Vault */
.financial-summary {
    display: flex;
    justify-content: space-between;
    background: var(--surface-light);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}
.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat .label { font-size: 0.8rem; color: var(--text-muted); }
.stat .value { font-size: 1.1rem; font-weight: 600; }

.transparency-note {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-style: italic;
}

/* Invoices List */
.invoice-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.invoice-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-base);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    border: 1px solid var(--border);
}
.inv-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.inv-info i { color: #EF4444; font-size: 1.2rem; }
.inv-status {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}
.inv-status.paid {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}
.inv-status.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.whatsapp-btn {
    background: #25D366;
    color: #fff;
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    cursor: pointer;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.checkbox-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Split-Screen Landing Grid */
.landing-container {
    grid-template-columns: 1.2fr 1fr;
}

@media (max-width: 1024px) {
    .landing-container {
        grid-template-columns: 1fr;
    }
    /* Force Asana Matrix to natively cleanly stack symmetrically */
    #asanaDashboardContainer {
        grid-template-columns: 1fr !important;
        gap: 24px !important;
    }
    #dashTimelineList {
        max-height: 380px !important;
    }
    .chart-container {
        height: 280px !important;
    }
}

@media (max-width: 768px) {
    .top-header {
        padding: 16px;
        flex-wrap: wrap;
        gap: 16px;
    }
    .view-section {
        padding: 0 16px;
    }
    .hero-section h1 {
        font-size: 1.8rem;
    }
    .forecast {
        font-size: 1rem;
        padding: 8px 20px;
    }
    .card {
        padding: 20px 16px;
    }
    .pm-snapshot-card {
        flex-direction: column;
        align-items: stretch !important;
        text-align: center;
    }
    .pm-snapshot-card > div:first-child {
        flex-direction: column;
        text-align: center;
    }
    .pm-snapshot-card > div:last-child {
        justify-content: center;
    }
    .labor-counter-flex {
        flex-direction: column;
        align-items: flex-start !important;
    }
    .labor-counter-flex > div:last-child {
        border-left: none !important;
        padding-left: 0 !important;
        text-align: left !important;
        border-top: 1px solid rgba(255,255,255,0.1);
        padding-top: 16px;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    #dashWorkersToday {
        font-size: 2.4rem !important;
    }
    .card-header h3 {
        font-size: 1.1rem !important;
    }
    .progress-dashboard-card > div > div:first-child {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 16px;
    }
    .progress-dashboard-card > div > div:first-child > div:last-child {
        text-align: left !important;
        border-left: none !important;
        padding-left: 0 !important;
        border-top: 1px solid rgba(255,255,255,0.1);
        padding-top: 16px;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}
