:root {
    --primary: #1A56DB;
    --primary-light: #3B82F6;
    --primary-dark: #1E40AF;
    --primary-surface: #EBF2FF;
    --bg-main: #F8FAFC;
    --bg-sidebar: #FFFFFF;
    --bg-card: #FFFFFF;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-tertiary: #94A3B8;
    --success: #16A34A;
    --warning: #F59E0B;
    --danger: #DC2626;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
aside {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
}

.logo-shield {
    background: var(--primary);
    color: white;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

nav {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
    width: 100%;
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary-surface);
    color: var(--primary);
    font-weight: 600;
}

.nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin: 1rem 1rem 0.5rem;
    font-weight: 700;
}

/* Main Content */
main {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.header-stats {
    display: flex;
    gap: 1.5rem;
}

.header-stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 6px 12px;
    border-radius: 50px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 600;
}

/* Cards */
.card {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 1.5rem;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: white;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.metric-title {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #F8FAFC;
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    vertical-align: middle;
}

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

.row-hover:hover {
    background: #FBFBFF;
}

/* Badges & Pills */
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-pending { background: #FEF3C7; color: #92400E; }
.badge-active { background: #DCFCE7; color: #166534; }
.badge-expired { background: #F1F5F9; color: #475569; }
.badge-rejected { background: #FEE2E2; color: #991B1B; }
.badge-info { background: #DBEAFE; color: #1D4ED8; }

/* Buttons */
.btn {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: white; border-color: var(--border); color: var(--text-secondary); }
.btn-outline:hover { background: var(--bg-main); color: var(--text-primary); }
.btn-danger { background: #FEE2E2; color: var(--danger); }
.btn-icon { padding: 6px; border-radius: 6px; }

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.9rem;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-surface);
}

.form-help {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    overflow: hidden;
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Alerts */
.system-alert {
    padding: 12px;
    border-radius: 10px;
    border: 1px solid;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}
.alert-success { background: #DCFCE7; border-color: #BBF7D0; color: #166534; }
.alert-error { background: #FEE2E2; border-color: #FECACA; color: #991B1B; }

.poi-type-tag {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #EBF2FF;
    color: var(--primary);
    font-weight: 600;
}

.map-placeholder {
    background: #e2e8f0;
    border-radius: 12px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-weight: 600;
    border: 2px dashed #cbd5e1;
}

.split-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.card-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper i {
    position: absolute;
    left: 10px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-wrapper input {
    padding-left: 32px !important;
    width: 220px;
}

.pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Custom pagination styling to ensure visibility and compatibility with Laravel default */
.pagination-links nav {
    display: flex;
    justify-content: flex-end;
}

.pagination-links ul {
    display: flex;
    list-style: none;
    gap: 4px;
    padding: 0;
    margin: 0;
}

.pagination-links li span, 
.pagination-links li a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.pagination-links li.active span,
.pagination-links li span[aria-current="page"] {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

.pagination-links li a:hover {
    background: var(--primary-surface);
    color: var(--primary);
    border-color: var(--primary);
}

.pagination-links li.disabled span {
    background: var(--bg-main);
    color: var(--text-tertiary);
    cursor: not-allowed;
    opacity: 0.6;
}

.pagination-links svg {
    width: 16px;
    height: 16px;
}

/* Hide the "Showing X to Y" text from Laravel's default pagination to avoid overlap */
.pagination-links nav > div:first-child {
    display: none !important;
}

.pagination-links nav > div:last-child {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
}

.pagination-links .flex.justify-between.flex-1 {
    display: none !important; /* Hide mobile-only duplicate links */
}

/* =============================================
   RESPONSIVE DESIGN
   ============================================= */

/* --- Hamburger Button (hidden on desktop) --- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

/* Sidebar overlay (for mobile) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* --- Tablet (≤1024px) --- */
@media (max-width: 1024px) {
    aside {
        width: 240px;
    }

    main {
        margin-left: 240px;
        padding: 1.5rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .split-grid {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .card-header-actions {
        flex-wrap: wrap;
    }
}

/* --- Small Tablet / Large Mobile (≤768px) --- */
@media (max-width: 768px) {
    .sidebar-toggle {
        display: flex;
    }

    aside {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
        z-index: 150;
    }

    aside.open {
        transform: translateX(0);
    }

    .sidebar-backdrop.open {
        display: block;
    }

    main {
        margin-left: 0;
        padding: 1rem;
        padding-top: 4.5rem; /* Space for toggle button */
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .header-stats {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header-stat-pill {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-value {
        font-size: 1.25rem;
    }

    /* Make tables horizontally scrollable */
    .card {
        overflow: hidden;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Stack card header elements */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-header form {
        width: 100%;
        flex-wrap: wrap;
    }

    .card-header form input[type="text"] {
        width: 100% !important;
        flex: 1;
    }

    /* Pagination footer stack */
    .pagination-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .pagination-links nav {
        justify-content: flex-start;
    }

    .split-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Period selector form */
    #dashboard-period-control form {
        padding: 4px 8px;
        font-size: 0.8rem;
    }

    .search-wrapper input {
        width: 140px !important;
    }

    .modal {
        width: 95%;
        margin: 0 auto;
    }

    .modal-body {
        max-height: 60vh;
    }
}

/* --- Mobile (≤480px) --- */
@media (max-width: 480px) {
    main {
        padding: 0.75rem;
        padding-top: 4.5rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .metric-card {
        padding: 0.75rem;
    }

    .metric-title {
        font-size: 0.65rem;
    }

    .metric-value {
        font-size: 1.1rem;
    }

    .card-header {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    td, th {
        padding: 0.65rem 0.75rem;
        font-size: 0.8rem;
    }

    .btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .btn-icon {
        padding: 5px;
    }

    .badge {
        font-size: 0.62rem;
        padding: 3px 6px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    header h1 {
        font-size: 1.1rem;
    }

    header p {
        font-size: 0.8rem;
    }

    .modal-header h3 {
        font-size: 0.95rem;
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}
