:root {
    --primary-50: #ecfdf5;
    --primary-100: #d1fae5;
    --primary-500: #10b981;
    --primary-600: #059669;
    --primary-700: #047857;
    --bg-gray: #f9fafb;
    --text-dark: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

html {
    font-size: 16px; /* Base size for desktop */
}

@media screen and (max-width: 1024px) {
    html {
        font-size: 15px; /* Standardize font scaling for tablets */
    }
}

@media screen and (max-width: 768px) {
    html {
        font-size: 14px; /* Standardize font scaling for mobile */
    }
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-dark);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

ul {
    list-style: none;
}

/* Utilities */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.py-16 { padding-top: 4rem; padding-bottom: 4rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-weight: 500;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

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

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

.btn-outline {
    border-color: var(--primary-500);
    color: var(--primary-500);
    background-color: transparent;
}

.btn-outline:hover {
    background-color: var(--primary-50);
}

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

.btn-white:hover {
    background-color: var(--bg-gray);
}

/* Header */
.header {
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 50;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    background-color: var(--primary-600);
    color: white;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-links a:not(.btn) {
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    padding: 0.45rem 0.85rem;
    border-radius: 0.5rem;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
}

.nav-links a:not(.btn):hover {
    color: #0f172a;
    background-color: #f1f5f9;
}

.nav-links a:not(.btn).active {
    color: #047857;
    background-color: #ecfdf5;
    box-shadow: inset 0 0 0 1px #a7f3d0;
}

/* Hero Section */
.hero {
    background-color: var(--primary-700);
    color: var(--white);
    padding: 6rem 1rem;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.hero p {
    font-size: 1.25rem;
    max-width: 48rem;
    margin: 0 auto 2rem auto;
    color: var(--primary-50);
}

.hero-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Cards */
.card {
    background-color: var(--white);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    border: 1px solid var(--border-color);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* Footer */
.footer {
    background-color: var(--white);
    border-top: 1px solid var(--border-color);
    padding: 3rem 0 0 0;
    margin-top: auto;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2rem;
}

.footer h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.footer ul {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer ul a {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer ul a:hover {
    color: var(--primary-600);
}

@media screen and (max-width: 768px) {
    .nav-links {
        display: none; /* replaced by drawer logic below */
    }
    .footer-grid {
        grid-template-columns: 1fr;
    }
    .hero h1 {
        font-size: 2rem;
    }
}

.mobile-sidebar-header {
    display: none;
}

/* Admin Styles */
.admin-body {
    background-color: #f3f4f6;
    padding-top: 4rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.admin-header {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #e2e8f0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
}

.admin-nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4.125rem;
    max-width: 100%;
    padding: 0 2rem;
}

.admin-nav-links {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin-left: auto;
    margin-right: 1.5rem;
}

.admin-nav-links a {
    font-size: 0.84rem;
    font-weight: 600;
    color: #475569;
    padding: 0.45rem 0.8rem;
    border-radius: 0.5rem;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
}

.admin-nav-links a:hover {
    color: #0f172a;
    background-color: #f1f5f9;
}

.admin-nav-links a.active {
    color: #047857;
    background-color: #ecfdf5;
    box-shadow: inset 0 0 0 1px #a7f3d0;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-btn, .dropdown-toggle {
    background: none;
    border: none;
    font-size: 0.84rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.8rem;
    border-radius: 0.5rem;
    font-family: inherit;
    transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none;
}

.dropdown-btn:hover, .dropdown-toggle:hover {
    color: #0f172a;
    background-color: #f1f5f9;
}

.dropdown-btn.active, .dropdown-toggle.active {
    color: #047857;
    background-color: #ecfdf5;
    box-shadow: inset 0 0 0 1px #a7f3d0;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #ffffff;
    min-width: 220px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    z-index: 100;
    padding: 0.5rem;
    margin-top: 0.35rem;
    animation: dropdownFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Invisible bridge to prevent hover loss */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -0.5rem;
    left: 0;
    right: 0;
    height: 0.5rem;
}

.dropdown:hover .dropdown-menu, .dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: flex !important;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.85rem;
    color: #334155 !important;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    text-decoration: none;
}

.dropdown-menu a:hover {
    background-color: #f8fafc;
    color: #059669 !important;
    transform: translateX(2px);
}

.dropdown-menu a.active {
    background-color: #ecfdf5;
    color: #047857 !important;
    font-weight: 600;
}

.admin-nav-actions {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.admin-main {
    padding: 2rem;
    flex: 1;
}

.admin-container {
    max-width: 1280px;
    margin: 0 auto;
}

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

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Responsive Global & Side Drawer Styles */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.mobile-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    padding: 0.25rem;
    z-index: 1000;
}

@media screen and (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }

    .hide-on-mobile {
        display: none !important;
    }

    .btn-responsive-icon {
        padding: 0.5rem !important;
        border-radius: 50% !important;
        width: 36px !important;
        height: 36px !important;
        justify-content: center !important;
    }

    .btn-responsive-icon i {
        margin-right: 0 !important;
    }

    .admin-nav-container, .header .container {
        justify-content: flex-start;
        gap: 1rem;
    }

    .admin-nav-actions {
        margin-left: auto;
        gap: 0.75rem;
    }
    
    .admin-nav-container > .logo, .header .container > .logo {
        flex: 1;
    }

    .nav-links, .admin-nav-links {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        height: 100%;
        background-color: var(--white);
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 0 1.5rem 2rem 1.5rem;
        margin: 0 !important;
        gap: 1rem;
        z-index: 999;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        display: flex; /* Override display: none from earlier */
        overflow-y: auto;
    }

    .mobile-sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        min-height: 4rem;
        margin-bottom: 0.5rem;
        padding-bottom: 0.5rem;
        padding-top: 0.5rem;
        padding-left: 3.5rem;
        border-bottom: 1px solid var(--border-color);
        width: 100%;
    }

    .mobile-sidebar-header span {
        font-size: 1.125rem !important;
        line-height: 1.3;
        padding-right: 1rem;
        flex: 1;
        word-wrap: break-word;
    }
    
    .mobile-sidebar-header a {
        flex-shrink: 0;
    }

    .nav-links.active, .admin-nav-links.active {
        left: 0;
    }

    .nav-links a, .admin-nav-links a, .dropdown-btn {
        padding: 0.75rem 0;
        font-size: 1rem;
        border-bottom: 1px solid var(--border-color);
        width: 100%;
        text-align: left;
    }

    .nav-links .dropdown-menu a, .admin-nav-links .dropdown-menu a {
        font-size: 0.9rem !important;
        border-bottom: none;
        padding: 0.5rem 0;
        color: var(--text-muted) !important;
    }

    .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        border-left: 2px solid var(--border-color);
        border-radius: 0;
        margin-top: 0;
        padding: 0 0 0 1rem;
        display: none;
    }
    
    .dropdown.active .dropdown-menu {
        display: block;
    }

    .admin-main {
        padding: 1rem;
    }

    /* Override inline grids to be single column */
    div[style*="grid-template-columns: 1fr 1fr;"],
    div[style*="grid-template-columns: 1fr 2fr;"],
    div[style*="grid-template-columns: 1fr 1fr 1fr;"],
    div[style*="grid-template-columns: repeat(3, 1fr);"],
    form[style*="grid-template-columns"],
    .card-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Stack page headers and inputs */
    div[id="page-header"],
    div[class*="page-header"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }
    div[id="page-header"] > div,
    div[class*="page-header"] > div {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }
    div[id="page-header"] input,
    div[id="page-header"] button:not(.icon-btn-circle) {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Stacked Card Table */
    table.card-table, table.card-table tbody {
        display: block;
        width: 100%;
        min-width: 0 !important;
    }
    table.card-table thead {
        display: none;
    }
    table.card-table tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        box-shadow: var(--shadow-sm);
        background-color: var(--white);
        padding: 0.5rem;
    }
    table.card-table td {
        display: block;
        position: relative;
        padding-left: 45% !important;
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
        padding-right: 0.5rem !important;
        border-bottom: 1px solid var(--border-color);
        text-align: right;
        word-break: break-word;
        min-height: 2.5rem;
    }
    table.card-table td:last-child {
        border-bottom: 0;
    }
    table.card-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0.5rem;
        top: 0.75rem;
        width: 40%;
        padding-right: 0.5rem;
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.75rem;
        color: var(--text-muted);
        text-align: left;
    }
    table.card-table td .btn, table.card-table td .btn-outline {
        margin-left: 0.5rem;
    }
    table.card-table td > div {
        text-align: right; /* Ensure contents inside td align right on mobile */
        max-width: 100%;
    }
    table.card-table td div[style*="display: flex"] {
        flex-wrap: wrap;
        justify-content: flex-end !important;
    }
}

/* ==========================================================================
   Header Location Badge & Geolocation Popover Styles
   ========================================================================== */
.header-location-widget {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.header-location-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    font-size: 0.775rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.2;
    max-width: 220px;
}

.header-location-btn:hover {
    background-color: #dcfce7;
    border-color: #86efac;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(22, 101, 52, 0.1);
}

.header-location-text {
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pulse status dots */
.loc-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.loc-pulse-green {
    background-color: #10b981;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: locPulseGreen 2s infinite;
}

.loc-pulse-amber {
    background-color: #f59e0b;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    animation: locPulseAmber 1.5s infinite;
}

.loc-pulse-red {
    background-color: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: locPulseRed 2s infinite;
}

@keyframes locPulseGreen {
    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 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes locPulseAmber {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

@keyframes locPulseRed {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Spinner */
.loc-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(37, 99, 235, 0.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: locSpin 0.7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

@keyframes locSpin {
    to { transform: rotate(360deg); }
}

/* Location Dropdown Card */
.header-location-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 300px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    z-index: 1050;
    padding: 1rem;
    display: none;
    animation: locFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-location-dropdown.show {
    display: block;
}

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

.loc-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.65rem;
    margin-bottom: 0.65rem;
    border-bottom: 1px solid #f1f5f9;
}

.loc-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.loc-detail-label {
    color: #64748b;
    font-weight: 500;
}

.loc-detail-val {
    color: #0f172a;
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

.loc-refresh-btn {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.15s ease;
}

.loc-refresh-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

@media screen and (max-width: 768px) {
    .header-location-btn {
        max-width: 160px;
        padding: 0.3rem 0.55rem;
    }
    .header-location-text {
        max-width: 90px;
    }
    .header-location-dropdown {
        right: -40px;
        width: 270px;
    }
}

@media screen and (max-width: 480px) {
    .header-location-text {
        display: none;
    }
    .header-location-btn {
        max-width: auto;
        padding: 0.4rem 0.5rem;
    }
}

