/* ==========================================================================
   Dhunge Dhara Water Turn System - Desktop & Mobile Dual Responsive Design
   ========================================================================== */

:root {
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;

    --primary-color: #142958;
    --primary-hover: #0f1f42;
    --primary-light: #cdd6e2;
    --primary-gradient: linear-gradient(135deg, #142958 0%, #1e3a8a 100%);

    --accent-warning: #d97706;
    --accent-success: #059669;

    --app-bg: #f4f7fa;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 20px -2px rgba(20, 41, 88, 0.08);
    --bottom-nav-bg: rgba(255, 255, 255, 0.95);
}

[data-bs-theme="dark"] {
    --bs-body-bg: #0f172a;
    --bs-body-color: #f8fafc;
    --bs-body-color-rgb: 248, 250, 252;
    --bs-secondary-color: #cbd5e1;
    --bs-secondary-color-rgb: 203, 213, 225;
    --bs-tertiary-bg: #1e293b;
    --bs-border-color: rgba(255, 255, 255, 0.1);

    --app-bg: #0f172a;
    --card-bg: #1e293b;
    --card-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);

    --primary-color: #38bdf8;
    --primary-hover: #0284c7;
    --primary-light: rgba(56, 189, 248, 0.15);
    --primary-gradient: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);

    --bottom-nav-bg: rgba(15, 23, 42, 0.95);
}

/* Explicit Dark Mode Professional Text Legibility Rules */
[data-bs-theme="dark"] h1, 
[data-bs-theme="dark"] h2, 
[data-bs-theme="dark"] h3, 
[data-bs-theme="dark"] h4, 
[data-bs-theme="dark"] h5, 
[data-bs-theme="dark"] h6,
[data-bs-theme="dark"] .text-body,
[data-bs-theme="dark"] .h1, 
[data-bs-theme="dark"] .h2, 
[data-bs-theme="dark"] .h3, 
[data-bs-theme="dark"] .h4, 
[data-bs-theme="dark"] .h5, 
[data-bs-theme="dark"] .h6 {
    color: #ffffff !important;
}

[data-bs-theme="dark"] p,
[data-bs-theme="dark"] label,
[data-bs-theme="dark"] .form-label {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-secondary {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .text-primary {
    color: #38bdf8 !important;
}

[data-bs-theme="dark"] .bg-primary-subtle {
    background-color: rgba(56, 189, 248, 0.15) !important;
    color: #38bdf8 !important;
}

[data-bs-theme="dark"] .bg-warning-subtle {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #fbbf24 !important;
}

[data-bs-theme="dark"] .bg-success-subtle {
    background-color: rgba(16, 185, 129, 0.15) !important;
    color: #34d399 !important;
}

[data-bs-theme="dark"] .card {
    background-color: #1e293b;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .mobile-queue-card,
[data-bs-theme="dark"] .bg-body {
    background-color: #1e293b !important;
}

[data-bs-theme="dark"] .bg-body-tertiary {
    background-color: #0f172a !important;
}

/* Light Mode Custom Styling (#142958 & #CDD6E2) */
[data-bs-theme="light"] {
    --bs-primary: #142958;
    --bs-primary-rgb: 20, 41, 88;
}

[data-bs-theme="light"] .btn-primary {
    background-color: #142958 !important;
    border-color: #142958 !important;
    color: #ffffff !important;
}

[data-bs-theme="light"] .btn-primary:hover, 
[data-bs-theme="light"] .btn-primary:focus, 
[data-bs-theme="light"] .btn-primary:active {
    background-color: #0f1f42 !important;
    border-color: #0f1f42 !important;
}

[data-bs-theme="light"] .btn-outline-primary {
    color: #142958 !important;
    border-color: #142958 !important;
}

[data-bs-theme="light"] .btn-outline-primary:hover, 
[data-bs-theme="light"] .btn-outline-primary:active {
    background-color: #142958 !important;
    color: #ffffff !important;
}

[data-bs-theme="light"] .text-primary {
    color: #142958 !important;
}

[data-bs-theme="light"] .bg-primary-subtle {
    background-color: #cdd6e2 !important;
    color: #142958 !important;
}

[data-bs-theme="light"] .border-primary-subtle {
    border-color: #b8c7d9 !important;
}

[data-bs-theme="light"] .token-badge {
    background-color: #cdd6e2 !important;
    color: #142958 !important;
    border-color: #b8c7d9 !important;
}

[data-bs-theme="light"] .desktop-icon-nav .nav-link:hover,
[data-bs-theme="light"] .desktop-icon-nav .nav-link.active {
    background-color: #cdd6e2 !important;
    color: #142958 !important;
}

body {
    font-family: var(--font-body);
    background-color: var(--app-bg);
    min-height: 100vh;
    margin: 0;
    padding-bottom: 85px; /* Mobile bottom nav space */
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 992px) {
    body {
        padding-bottom: 0; /* Remove bottom nav space on desktop */
    }
}

.font-heading {
    font-family: var(--font-heading);
}

/* App Viewport Container (Responsive Desktop & Mobile) */
.app-container-shell {
    width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background-color: var(--app-bg);
}

@media (min-width: 992px) {
    .app-container-shell {
        max-width: 1240px;
    }
}

/* Custom Navbar & Desktop Icon-Only Navigation */
.custom-navbar {
    background-color: var(--bottom-nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 0.75rem 1rem;
}

/* Desktop Icon-Only Navigation Bar with Floating Non-Shifting Hover Popups */
.desktop-icon-nav .nav-item {
    position: relative;
}

.desktop-icon-nav .nav-link {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-body-color);
    background-color: transparent;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
    text-decoration: none;
    font-size: 1.2rem;
}

.desktop-icon-nav .nav-link:hover,
.desktop-icon-nav .nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary-color) !important;
    transform: translateY(-2px);
}

/* Floating Popup Menu Label (No Layout Shift) */
.desktop-icon-nav .nav-item .nav-popup {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background-color: #0f172a;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 0.4rem;
    white-space: nowrap;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.2s ease;
    z-index: 1080;
}

[data-bs-theme="dark"] .desktop-icon-nav .nav-item .nav-popup {
    background-color: #1e293b;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Popup Arrow */
.desktop-icon-nav .nav-item .nav-popup::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: transparent transparent #0f172a transparent;
}

[data-bs-theme="dark"] .desktop-icon-nav .nav-item .nav-popup::before {
    border-color: transparent transparent #1e293b transparent;
}

/* Show Floating Popup on Hover */
.desktop-icon-nav .nav-item:hover .nav-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Touch Targets & Buttons */
.touch-target {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.touch-target:active {
    transform: scale(0.97);
}

/* Hero Status Card Gradient */
.hero-card {
    background: var(--primary-gradient);
    box-shadow: 0 12px 25px -5px rgba(37, 99, 235, 0.3);
}

/* Mobile Fixed Bottom Navigation Bar (Hidden on Desktop) */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 520px;
    height: 70px;
    background: var(--bottom-nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1040;
    padding: 0 0.5rem;
}

@media (min-width: 992px) {
    .mobile-bottom-nav {
        display: none !important; /* Hide mobile nav on desktop */
    }
}

[data-bs-theme="dark"] .mobile-bottom-nav {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 600;
    flex: 1;
    transition: color 0.2s ease, transform 0.15s ease;
}

.mobile-nav-item i {
    margin-bottom: 2px;
}

.mobile-nav-item.active, .mobile-nav-item:active {
    color: var(--primary-color);
    transform: scale(1.05);
}

/* Center Floating Action Button (FAB) */
.mobile-fab-wrapper {
    position: relative;
    top: -18px;
}

.mobile-fab-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.4);
    border: 3px solid var(--card-bg);
    text-decoration: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mobile-fab-btn:active {
    transform: scale(0.92);
}

/* Mobile & Desktop Card Items */
.mobile-queue-card {
    background-color: var(--card-bg);
    box-shadow: var(--card-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mobile-queue-card:hover {
    box-shadow: 0 8px 30px -4px rgba(0, 0, 0, 0.1);
}

/* Utility Animations & Typography */
.fs-7 { font-size: 0.875rem; }
.fs-8 { font-size: 0.775rem; }
.fs-9 { font-size: 0.65rem; }

.animated-bounce {
    animation: bounce 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

/* Floating PWA Install Prompt Banner at TOP of Screen (Android & iOS) */
.pwa-install-banner {
    position: fixed;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 1.5rem);
    max-width: 520px;
    z-index: 1090;
    box-shadow: 0 12px 30px -5px rgba(0, 0, 0, 0.3) !important;
    animation: slideDownPwa 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 992px) {
    .pwa-install-banner {
        top: 85px;
    }
}

@keyframes slideDownPwa {
    from {
        transform: translate(-50%, -80px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}
