/* Google Fonts: Plus Jakarta Sans */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --secondary: #0ea5e9;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --dark: #0f172a;
    --dark-light: #1e293b;
    --gray-light: #f8fafc;
    --gray-border: #e2e8f0;
    --text-main: #334155;
    --text-muted: #64748b;
    --sidebar-width: 260px;
    --border-radius: 12px;
    --box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.08), 0 2px 8px -1px rgba(15, 23, 42, 0.04);
    --transition: all 0.25s ease;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-main);
    background-color: var(--gray-light);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Application Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--dark);
    color: #f1f5f9;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    border-right: 1px solid var(--dark-light);
}

.sidebar-brand {
    padding: 24px;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--dark-light);
}

.sidebar-menu {
    list-style: none;
    padding: 20px 12px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}

.sidebar-item a:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-item.active a {
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--dark-light);
    font-size: 0.8rem;
    color: #64748b;
    text-align: center;
}

/* Main Content Styling */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
}

/* Public Layout (No Sidebar) */
.app-wrapper.public-layout .main-content {
    margin-left: 0;
    width: 100%;
}

/* Header/Navbar Styling */
.top-navbar {
    height: 70px;
    background-color: #fff;
    border-bottom: 1px solid var(--gray-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.page-title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.5px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

/* Content Frame */
.content-body {
    padding: 30px;
    flex-grow: 1;
}

/* Card Styling */
.stats-card {
    background: #fff;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-border);
    padding: 24px;
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stats-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 16px -6px rgba(15, 23, 42, 0.05);
}

.stats-info h5 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 6px 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-info h3 {
    font-size: 1.8rem;
    color: var(--dark);
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stats-icon.primary { background-color: rgba(79, 70, 229, 0.1); color: var(--primary); }
.stats-icon.success { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.stats-icon.warning { background-color: rgba(245, 158, 11, 0.1); color: var(--warning); }
.stats-icon.danger { background-color: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Premium Table Styling */
.table-responsive-custom {
    background: #fff;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-border);
    box-shadow: var(--box-shadow);
    overflow-x: auto;
    margin-bottom: 24px;
}

.custom-table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
}

.custom-table th {
    background-color: #fafbfc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--gray-border);
}

.custom-table td {
    padding: 18px 24px;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--gray-border);
    color: var(--text-main);
    vertical-align: middle;
}

.custom-table tr:last-child td {
    border-bottom: none;
}

.custom-table tr:hover td {
    background-color: #f8fafc;
}

/* Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-badge.empty {
    background-color: var(--success-light);
    color: var(--success);
}

.status-badge.occupied {
    background-color: var(--danger-light);
    color: var(--danger);
}

.status-badge.warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

/* Map Containers */
#map, #map-picker {
    height: 500px;
    width: 100%;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--gray-border);
    z-index: 1;
}

/* Customized Leaflet Popups */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 5px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.leaflet-popup-content h6 {
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 6px;
}

.leaflet-popup-content p {
    margin: 4px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Form Styles */
.custom-form-card {
    background: #fff;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-border);
    box-shadow: var(--box-shadow);
    padding: 30px;
}

.form-label {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--gray-border);
    padding: 10px 14px;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    outline: none;
}

.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn-primary-custom:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
    color: white;
}

.btn-secondary-custom {
    background-color: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--gray-border);
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-secondary-custom:hover {
    background-color: #e2e8f0;
}

/* Map Filter Controls */
.map-filter-group {
    background: white;
    padding: 10px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--gray-border);
    display: inline-flex;
    gap: 8px;
    margin-bottom: 15px;
}

.map-filter-btn {
    border: none;
    background: none;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 20px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.map-filter-btn:hover {
    background-color: #f1f5f9;
}

.map-filter-btn.active {
    background-color: var(--dark);
    color: white;
}

/* Ledger (Ekstre) Styling */
.ledger-row.debit {
    border-left: 4px solid var(--danger);
}

.ledger-row.credit {
    border-left: 4px solid var(--success);
}

/* Mobile Responsive Adjustments */
@media (max-width: 991.98px) {
    .app-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--dark-light);
    }
    
    .sidebar-brand {
        padding: 20px;
        justify-content: center;
    }
    
    .sidebar-menu {
        flex-direction: row;
        overflow-x: auto;
        padding: 10px 15px;
        gap: 10px;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar-item a {
        padding: 10px 14px;
        font-size: 0.85rem;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        min-height: auto;
    }
    
    .top-navbar {
        padding: 0 20px;
        height: 60px;
    }
    
    .content-body {
        padding: 20px 15px;
    }
    
    #map, #map-picker {
        height: 350px;
    }
    
    .stats-card {
        padding: 18px;
    }
    
    .stats-info h3 {
        font-size: 1.5rem;
    }
    
    .custom-form-card {
        padding: 20px;
    }
}

@media (max-width: 575.98px) {
    .sidebar-menu {
        padding: 10px;
        gap: 6px;
    }
    
    .sidebar-item a {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
    
    .page-title {
        font-size: 1.1rem;
    }
    
    .user-profile .fw-bold {
        font-size: 0.8rem;
    }
}

/* Portal/Requests utility classes */
#portal-map {
    width: 100%;
    border: 1px solid var(--gray-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.bg-success-light {
    background-color: var(--success-light) !important;
}

.bg-danger-light {
    background-color: var(--danger-light) !important;
}

.bg-warning-light {
    background-color: var(--warning-light) !important;
}

.border-success-light {
    border: 1px solid rgba(16, 185, 129, 0.2) !important;
}

.border-danger-light {
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
}

.border-warning-light {
    border: 1px solid rgba(245, 158, 11, 0.2) !important;
}

/* Clickable Billboard Image Styling */
.clickable-billboard-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 8px;
    display: block;
    border: 1px solid var(--gray-border);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), filter 0.3s ease, box-shadow 0.3s ease;
}

.clickable-billboard-img:hover {
    transform: scale(1.03);
    filter: brightness(0.9);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

/* Premium Image Preview Modal Backdrop & Styles */
#imagePreviewModal {
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
}

#imagePreviewModal .modal-dialog {
    max-width: 850px;
}

#imagePreviewModal #previewImage {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#imagePreviewModal.show #previewImage {
    transform: scale(1);
}