/* Municipal Challan App CSS Variables and Global Layout */

:root {
    --primary: #1976d2;
    --primary-dark: #1565c0;
    --primary-light: #e3f2fd;
    --accent: #ff9800;
    
    --bg-app: #f4f6f9;
    --bg-card: #ffffff;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-hint: #bdbdbd;
    
    --border-color: #e0e0e0;
    
    --status-paid: #2e7d32;
    --status-unpaid: #c62828;
    --status-partial: #ef6c00;
    --status-cancelled: #37474f;
    --status-draft: #616161;
    
    --header-height: 56px;
    --transition-speed: 0.3s;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    color: var(--text-primary);
    background-color: var(--bg-app);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* App Viewport Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: relative;
}

.app-header {
    height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: 16px;
    padding-right: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 50;
    position: relative;
    flex-shrink: 0;
}

.app-header.hidden {
    display: none;
}

.header-title {
    font-size: 20px;
    font-weight: 500;
    margin-left: 16px;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-btn {
    background: none;
    border: none;
    color: white;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.header-btn:active {
    background-color: rgba(255,255,255,0.1);
}

.network-badge {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.network-badge.online {
    background-color: rgba(255,255,255,0.2);
    color: #fff;
}

.network-badge.offline {
    background-color: #d32f2f;
    color: #fff;
}

.app-viewport {
    flex-grow: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* Sidebar / Navigation Drawer */
.nav-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    background-color: white;
    z-index: 2100;
    box-shadow: 2px 0 10px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-drawer.open {
    transform: translateX(0);
}

.drawer-overlay {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed) ease;
}

.drawer-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.drawer-header {
    background-color: var(--primary);
    color: white;
    padding: calc(24px + env(safe-area-inset-top, 0px)) 16px 24px 16px;
    display: flex;
    align-items: center;
}

.drawer-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: white;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    margin-right: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.drawer-title-group {
    display: flex;
    flex-direction: column;
}

.drawer-title {
    font-size: 18px;
    font-weight: 600;
}

.drawer-subtitle {
    font-size: 13px;
    color: var(--primary-light);
    margin-top: 4px;
}

.drawer-menu {
    list-style: none;
    padding: 8px 0;
    overflow-y: auto;
    flex-grow: 1;
}

.menu-item {
    display: block;
    padding: 16px 24px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    transition: background-color 0.2s;
}

.menu-item:active, .menu-item.active {
    background-color: #f0f0f0;
    color: var(--primary);
}

.menu-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 8px 0;
}

.logout-item {
    color: var(--status-unpaid);
}

/* Modals */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-container.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    right: 16px;
    z-index: 4000;
    pointer-events: none;
}

.toast {
    background-color: #323232;
    color: white;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background-color: var(--status-unpaid);
}

.toast.success {
    background-color: var(--status-paid);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.8);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Bottom Tab Navigation Bar */
.bottom-tab-bar {
    display: flex;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    background-color: var(--primary);
    border-top: 1px solid var(--primary-dark);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
    z-index: 50;
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-tab-bar.hidden {
    display: none !important;
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: color 0.2s, background-color 0.2s;
    position: relative;
}

.tab-item:active {
    background-color: var(--primary-dark);
}

.tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-bottom: 3px;
    transition: transform 0.2s ease;
}

.tab-item.active {
    color: #ffffff;
    font-weight: 700;
}

/* Active top line highlight indicator */
.tab-item.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background-color: #ffffff;
    border-radius: 0 0 3px 3px;
}

/* Accent active scale pop */
.tab-item.active .tab-icon {
    transform: scale(1.12);
}

/* Leaflet Map Scoping & Stacking Context Isolation */
#form-gps-map,
#detail-gps-map,
.leaflet-container {
    z-index: 1 !important;
    isolation: isolate;
}

