/* ==========================================================================
   MUMBAI NAZAFAT APP - MASTER PLATFORM STYLESHEET
   THEME: DAYLIGHT CLEAN (HIGH-VISIBILITY, GLASSMORPHIC)
   ========================================================================== */

:root {
    /* Core Daylight Canvas */
    --bg-main: #f1f5f9;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --bg-surface-elevated: rgba(255, 255, 255, 1);
    
    /* Branding & Tactical Accents */
    --primary: #007b83;
    --primary-light: rgba(0, 123, 131, 0.1);
    --primary-hover: #006970;
    --success: #16a34a;
    --success-light: rgba(22, 163, 74, 0.15);
    --warning: #eab308;
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    
    /* Typography Inverted for Light Mode */
    --text-main: #0f172a;
    --text-muted: #64748b;
    
    /* Glassmorphism Structural Borders */
    --border-color: rgba(0, 0, 0, 0.08);
    --glass-blur: blur(15px);
}

/* --- SYSTEM FRAMEWORK RESET MATRIX --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    overscroll-behavior-y: contain; /* Prevents native pull-to-refresh conflicts */
}

/* --- FIXED VIEWPORT RIGID BOUNDARIES --- */
.app-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start !important;
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* --- BRANDING ASSETS --- */
.brand-icon {
    width: 35px;
    height: 35px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,123,131,0.3));
}

/* --- PERSISTENT DESKTOP NAVIGATION SIDEBAR --- */
.sidebar {
    width: 280px;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 25px 20px;
    flex-shrink: 0;
    z-index: 100;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 35px;
    padding-left: 10px;
}

.sidebar-brand span { color: var(--primary); }

/* --- MAIN WORKSPACE WORK TRACK LAYOUT WRAPPER --- */
.main-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start !important;
    min-width: 0;
    min-height: 0;
    height: 100vh;
    position: relative;
    margin-top: 0 !important;
}

/* --- TOP STATUS BAR (GLASSMORPHIC) --- */
.topbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 90;
    color: var(--text-main);
    margin-top: 0 !important;
}

.topbar-title-block h2 {
    font-weight: 900;
    letter-spacing: 1px;
    color: var(--text-main);
    font-size: 1.1em;
}

.topbar-title-block p {
    font-size: 0.8em;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 2px;
}

.user-profile-tag {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    padding: 6px 14px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
}

.header-logo {
    height: 85px;
    object-fit: contain;
    max-width: 200px;
    flex-shrink: 0;
}

.topbar-right-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
}

.avatar-sphere {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: #fff;
    font-size: 0.9em;
}

/* --- PULL TO REFRESH SPINNER --- */
.ptr-loader {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 95;
    transition: top 0.2s ease;
}
@keyframes spin { 0% { transform: translateX(-50%) rotate(0deg); } 100% { transform: translateX(-50%) rotate(360deg); } }

/* --- SCROLLABLE VIEWPORT --- */
.views-viewport {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    width: 100%;
    position: relative;
}

.view-section {
    width: 100%;
    animation: fadeInView 0.2s ease-out forwards;
}

@keyframes fadeInView {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- SIDEBAR NAV ITEMS --- */
.nav-item {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 13px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    margin-bottom: 4px;
    min-height: 48px;
}

.nav-item i { font-size: 1.1em; width: 24px; text-align: center; }
.nav-item:hover { color: var(--primary); background-color: var(--primary-light); }
.nav-item.active {
    color: #fff;
    background-color: var(--primary) !important;
    box-shadow: 0 4px 12px rgba(0, 123, 131, 0.3);
}

/* --- GLASSMORPHIC CARDS --- */
.control-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
}

.card-title {
    font-size: 0.85em;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.stat-card {
    text-align: center;
    padding: 16px;
    border-radius: 12px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
}

.stat-title { font-size: 0.75em; font-weight: 800; color: var(--text-muted); text-transform: uppercase; }
.stat-value { font-size: 1.5em; font-weight: 900; color: var(--primary); margin-top: 4px; }

/* --- INPUTS & FORMS (ONE-HANDED SIZING) --- */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
}

.input-group label {
    font-size: 0.75em;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input, 
.input-group select, 
.input-group textarea {
    width: 100%;
    background-color: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    font-size: 1em;
    font-weight: 600;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.input-group input:focus, 
.input-group select:focus, 
.input-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 131, 0.15);
    background-color: #ffffff;
}

.input-locked {
    background-color: #f8fafc !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
    border: 1px dashed var(--border-color) !important;
}

/* --- TACTICAL BUTTON MATRIX --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 22px;
    min-height: 48px;
    font-size: 0.9em;
    font-weight: 800;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary { background-color: var(--primary); color: #fff; }
.btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-1px); }
.btn-outline { background: #ffffff; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background-color: var(--danger); color: #fff; }
.btn-success { background-color: var(--success); color: #fff; }
.btn-warning { background-color: var(--warning); color: #fff; }

/* NEON SOS BUTTON */
.btn-sos {
    background-color: var(--danger);
    color: #fff;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    animation: sosPulse 1.5s infinite;
    font-weight: 900;
}
@keyframes sosPulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    70% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* FLOATING GLOBAL QR SCAN BUTTON */
.floating-scan-btn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    box-shadow: 0 4px 20px rgba(0, 123, 131, 0.3);
    z-index: 1000;
    cursor: pointer;
    border: none;
}

/* --- DYNAMIC OUTPUT RENDER LIST ITEMS --- */
.list-item {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-main { display: flex; flex-direction: column; min-width: 0; }
.item-name { font-size: 0.95em; font-weight: 800; color: var(--text-main); }
.item-sub { font-size: 0.8em; font-weight: 700; color: var(--text-muted); margin-top: 2px; }
.qty-calc-group { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.qty-pill { background: #f1f5f9; padding: 6px 12px; border-radius: 20px; font-size: 0.8em; font-weight: 900; border: 1px solid var(--border-color); color: var(--text-main); }
.item-total { font-size: 1.1em; font-weight: 900; color: var(--success); min-width: 75px; text-align: right; }
.category-header { font-size: 0.8em; font-weight: 900; color: var(--primary); text-transform: uppercase; margin: 25px 0 12px 4px; border-left: 3px solid var(--primary); padding-left: 10px; }

/* --- ARCHITECTURE GRID ATTENDANCE TABLES --- */
.attendance-table-wrapper { width: 100%; overflow-x: auto; border-radius: 12px; border: 1px solid var(--border-color); background: #ffffff; }
table { width: 100%; border-collapse: collapse; text-align: left; min-width: 600px; color: var(--text-main); }
th, td { padding: 16px 18px; border-bottom: 1px solid var(--border-color); font-size: 0.9em; }
th { background-color: rgba(0,0,0,0.03); font-weight: 800; text-transform: uppercase; font-size: 0.75em; color: var(--text-muted); }
td { font-weight: 700; }

/* --- LIVE TRACKING GRAPHS --- */
.progress-bar-bg { width: 100%; background-color: rgba(0,0,0,0.05); border-radius: 10px; height: 16px; margin-top: 8px; border: 1px solid var(--border-color); overflow: hidden; }
.progress-bar-fill { height: 100%; background-color: var(--primary); border-radius: 10px; transition: width 0.4s ease; }

/* --- STICKY NAVIGATION SUB-TABS OVERLAYS --- */
.sticky-tabs { position: sticky; top: 0; z-index: 80; background: rgba(255, 255, 255, 0.95); backdrop-filter: var(--glass-blur); padding: 12px 0; margin-bottom: 15px; border-bottom: 1px solid var(--border-color); }
.mobile-grid-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }

/* --- LABORER RACK TOGGLE GRID --- */
.rack-toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}
.rack-btn {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 10px;
    text-align: center;
    color: var(--text-main);
    font-weight: 900;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
}
.rack-btn.full {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* --- TIERED BROADCAST POPUP (Z-INDEX SUPERIOR) --- */
.broadcast-overlay {
    position: fixed; top:0; left:0; width:100vw; height:100vh;
    background: rgba(255,255,255,0.85); backdrop-filter: blur(10px);
    z-index: 3000; display: flex; align-items: center; justify-content: center;
}
.broadcast-card {
    background: #ffffff; border: 2px solid var(--primary); border-radius: 20px;
    padding: 30px; width: 90%; max-width: 450px; text-align: center;
    box-shadow: 0 10px 40px rgba(0, 123, 131, 0.15);
}

/* --- RESPONSIVE BOTTOM MOBILE MENU INTERFACES --- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; width: 100vw; height: 75px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border-color);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav .nav-item { flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 0; margin: 0; height: 100%; border-radius: 0; min-height: auto; }
.bottom-nav .nav-item i { font-size: 1.4em; }
.bottom-nav .nav-item span { font-size: 0.7em; font-weight: 800; }
.bottom-nav .nav-item.active { background: transparent !important; color: var(--primary); box-shadow: none; }

/* --- POPUPS MODAL SYSTEM WRAPPERS --- */
.modal-overlay { display: flex; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(6px); z-index: 2000; align-items: center; justify-content: center; }
.modal-content { background: var(--bg-surface-elevated); backdrop-filter: var(--glass-blur); border: 1px solid var(--border-color); border-radius: 20px; padding: 25px; box-shadow: 0 15px 40px rgba(0,0,0,0.1); }

/* MOBILE DRAWER SHEET (SLIDES UP) */
.drawer-sheet {
    width: 100%; border-radius: 24px 24px 0 0; margin: 0; padding: 25px 25px 35px 25px; 
    background: var(--bg-surface-elevated); backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border-color);
    position: fixed; bottom: -100%; left: 0;
    transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2001;
}
.drawer-sheet.open { bottom: 0; }
#drawer-overlay { display: none; opacity: 0; transition: opacity 0.3s ease; }
#drawer-overlay.active { display: flex; opacity: 1; }

.drawer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 15px; }
.drawer-item { display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--bg-main); padding: 15px; border-radius: 15px; border: 1px solid var(--border-color); color: var(--text-main); text-decoration: none; border:none; cursor: pointer;}
.drawer-item i { font-size: 1.5em; color: var(--primary); }
.drawer-item span { font-size: 0.75em; font-weight: 700; text-align: center; }

/* --- SYSTEM VIEWPORT RESPONSIVE BREAKPOINTS --- */
@media (max-width: 1024px) {
    .sidebar { width: 80px; padding: 25px 10px; align-items: center; }
    .sidebar-brand h1, .nav-item span { display: none; }
    .nav-item { justify-content: center; padding: 14px; }
    .nav-item i { font-size: 1.4em; }
    .views-viewport { padding: 20px; }
}

@media (max-width: 768px) {
    .sidebar { display: none !important; }
    .bottom-nav { display: flex !important; }
    .topbar { padding: 10px 12px; position: sticky; top: 0; width: 100%; }
    .header-logo { height: 40px; max-width: 110px; }
    .topbar-right-actions { gap: 5px; }
    .hide-mobile { display: none !important; }
    .user-profile-tag { padding: 4px 8px; gap: 6px; }
    .user-profile-tag span { font-size: 0.8em; }
    .views-viewport { padding: 12px 10px 90px 10px; } 
    .mobile-grid-tabs { gap: 4px; }
    .mobile-grid-tabs .btn { padding: 10px 4px; font-size: 0.65em; }
    .floating-scan-btn { bottom: 90px; right: 12px; width: 50px; height: 50px; font-size: 1.2em; }
    
    /* Make touch targets appropriate for small screens like iPhone 6S */
    .input-group input, .input-group select, .input-group textarea, .btn { font-size: 0.9em; padding: 12px; }
    
    /* Compress containers */
    .control-card { padding: 12px; margin-bottom: 15px; }
    .modal-content { padding: 15px; width: 95%; max-height: 90vh; overflow-y: auto; }
    .styled-row-card { padding: 12px; flex-direction: column; align-items: flex-start; gap: 8px; }
    .styled-row-card .row-right { align-self: flex-end; }
    .drawer-grid { gap: 8px; }
    .drawer-item { padding: 10px; }
    .drawer-item i { font-size: 1.2em; }
    .drawer-item span { font-size: 0.65em; }
    
    .attendance-table-wrapper { border-radius: 8px; }
    th, td { padding: 10px 8px; font-size: 0.8em; }
    
    .mobile-back-btn { display: flex !important; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-surface-elevated); color: var(--primary); border: 1px solid var(--border-light); font-size: 1.1em; cursor: pointer; flex-shrink: 0; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
}

.mobile-back-btn { display: none; }

/* ==========================================================================
   ADVANCED STYLED ROW CARDS (HIGH-FIDELITY ESTIMATION TABLES)
   ========================================================================== */

.styled-row-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    border: 1px solid var(--border-color);
}

.styled-row-card .row-left {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.styled-row-card .row-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e2e8f0; 
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 0.6em;
    margin-top: 4px;
    box-shadow: inset 0 0 0 2px #cbd5e1;
}

.styled-row-card .row-icon i {
    font-size: 1.2em;
}

.styled-row-card .row-text {
    display: flex;
    flex-direction: column;
}

.styled-row-card .row-text h4 {
    font-size: 1em;
    font-weight: 900;
    color: #0f172a;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.styled-row-card .row-text p {
    font-size: 0.75em;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.styled-row-card .row-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #d97706; /* Orange */
    color: white;
    border-radius: 20px;
    font-size: 0.65em;
    font-weight: 900;
    width: max-content;
}

.styled-row-card .row-badge.gray { 
    background: #94a3b8; 
}

.styled-row-card .row-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
}

.styled-row-card .value-box {
    background: #f3e8ff; /* Light purple */
    color: #0f172a;
    padding: 10px 16px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.styled-row-card .value-box .value {
    font-size: 1.2em;
    font-weight: 900;
    line-height: 1;
}

.styled-row-card .value-box .unit {
    font-size: 0.65em;
    font-weight: 800;
    margin-top: 2px;
}

.styled-row-card .cost-sub {
    font-size: 0.95em;
    font-weight: 900;
    color: #007b83; /* Teal */
    margin-top: 8px;
}

/* Specific styling for Grand Total Card */
.styled-row-card.grand-total {
    background: #a5f3fc; /* Teal light */
    border-color: #0891b2;
}

.styled-row-card.grand-total .value-box {
    background: #164e63;
    color: white;
}

.styled-row-card.grand-total .row-badge {
    background: #737373;
}

@media print {
    .hide-on-print {
        display: none !important;
    }
}

/* Live Feed Fullscreen Mode */
.live-feed-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9999 !important;
    background: var(--bg-main) !important;
    padding: 20px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
}

.live-feed-fullscreen .control-card {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.live-feed-fullscreen #liveFeedTimeline {
    max-height: none !important;
    flex-grow: 1 !important;
    overflow-y: auto !important;
}
/* Admin Financial Controls */
body:not(.is-admin) .cost-sub,
body:not(.is-admin) .admin-only-cost,
body:not(.is-admin) #adminFinancialDashboard,
body:not(.is-admin) .input-group:has(#waste_bagCostInput),
body:not(.is-admin) .input-group:has(#shoe_rackCostInput),
body:not(.is-admin) .input-group:has(#shoe_laborCostInput),
body:not(.is-admin) .input-group:has(#shoe_bagCostInput),
body:not(.is-admin) .input-group:has(#shoe_tokenCostInput) {
    display: none !important;
}

