:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #e0e7ff;
    --secondary: #0f172a;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --sidebar-width: 260px;
    --header-height: 64px;
    --border-radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --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);
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: var(--primary);
}

/* ===== LOGIN PAGE ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: url('../images/background.jpeg') center center/cover no-repeat;
    padding: 20px;
    position: relative;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(173, 216, 230, 0.5);
    z-index: 1;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 2;
}

.login-card .logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .logo img {
    height: 56px;
    margin-bottom: 12px;
}

.login-card .logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.login-card .logo p {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

.login-card .logo .company-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    margin-top: 12px;
    line-height: 1.4;
}

.login-card .logo .contact-info {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 6px;
    line-height: 1.4;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 14px;
    color: var(--gray-800);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

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

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #1a8a6e 0%, #2d6a8a 100%);
    color: #fff;
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #157a5e 0%, #255a7a 100%);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: #fff;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    margin-bottom: 16px;
    display: none;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ===== LAYOUT ===== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--secondary);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header img {
    height: 36px;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--gray-400);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-nav a .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    color: var(--gray-500);
    text-align: center;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: url('../images/background.jpeg') center center/cover no-repeat fixed;
    position: relative;
}

.main-content::before {
    content: '';
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    background: rgba(173, 216, 230, 0.5);
    z-index: 0;
    pointer-events: none;
}

.header {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}

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

.header-actions .admin-info {
    font-size: 13px;
    color: var(--gray-500);
}

.profile-wrapper {
    position: relative;
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: 50px;
    padding: 6px 14px 6px 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.profile-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    z-index: 200;
    display: none;
    overflow: hidden;
}

.profile-dropdown.active {
    display: block;
}

.profile-dropdown-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar-lg {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.profile-info-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

.profile-info-email {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--gray-200);
}

.profile-dropdown-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-700);
    transition: background 0.15s;
    text-align: left;
}

.profile-dropdown-item:hover {
    background: var(--gray-50);
}

.profile-dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--gray-400);
}

.profile-dropdown-logout {
    color: var(--danger);
    border-top: 1px solid var(--gray-200);
}

.profile-dropdown-logout i {
    color: var(--danger);
}

.profile-dropdown-logout:hover {
    background: #fef2f2;
}

.content {
    flex: 1;
    min-width: 0;
    padding: 32px;
    position: relative;
    z-index: 1;
}

/* ===== CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.stat-card.green {
    border-left-color: var(--success);
}

.stat-card.orange {
    border-left-color: var(--warning);
}

.stat-card.blue {
    border-left-color: var(--info);
}

.stat-card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
}

/* ===== PANEL / TABLE ===== */
.panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.panel-body {
    padding: 24px;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 0;
    min-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 14px;
    white-space: nowrap;
}

table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

table tr:hover {
    background: var(--gray-50);
}

table .actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

/* ===== FILTERS ===== */
.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    align-items: flex-end;
}

.filters .form-group {
    margin-bottom: 0;
    min-width: 180px;
}

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 0;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--gray-300);
    background: #fff;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    transition: all 0.2s;
}

.pagination button:hover {
    background: var(--gray-100);
}

.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== BADGE ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-open {
    background: #fef3c7;
    color: #92400e;
}

.badge-closed {
    background: #d1fae5;
    color: #065f46;
}

/* ===== MAP ===== */
#map {
    width: 100%;
    height: 500px;
    border-radius: var(--border-radius);
}

/* ===== CHART ===== */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

.chart-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.chart-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--gray-800);
}

/* ===== RESPONSIVE ===== */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-700);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 300;
    }

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

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 299;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: block;
    }

    .login-card {
        padding: 32px 24px;
    }

    .login-card .logo h1 {
        font-size: 20px;
    }

    .header {
        padding: 0 12px;
    }

    .header h1 {
        font-size: 16px;
    }

    .content {
        padding: 16px 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .value {
        font-size: 24px;
    }

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

    .filters {
        flex-direction: column;
    }

    .filters .form-group {
        width: 100%;
        min-width: 0;
    }

    .panel-header {
        padding: 14px 16px;
        flex-direction: column;
        align-items: flex-start;
    }

    .panel-header .btn {
        width: 100%;
        justify-content: center;
    }

    .panel-body {
        padding: 16px;
    }

    table th,
    table td {
        padding: 10px 8px;
        font-size: 12px;
        white-space: nowrap;
    }

    table .actions {
        gap: 4px;
    }

    table .actions .btn {
        padding: 4px 6px;
        font-size: 11px;
    }

    .modal-overlay {
        padding: 12px;
        align-items: flex-start;
        padding-top: 60px;
    }

    .modal {
        max-width: 100%;
        max-height: calc(100vh - 80px);
        border-radius: 10px;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-header h3 {
        font-size: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
    }

    .pagination {
        gap: 4px;
        padding: 14px 0;
        flex-wrap: wrap;
    }

    .pagination button {
        padding: 6px 10px;
        font-size: 12px;
    }

    #map {
        height: 350px;
    }

    .chart-card {
        padding: 16px;
    }

    .profile-name {
        display: none;
    }

    .profile-btn {
        padding: 4px 8px 4px 4px;
    }

    .profile-btn .fa-chevron-down {
        display: none;
    }

    .profile-dropdown {
        width: 260px;
        right: -8px;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar input {
        min-width: 0;
        width: 100%;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .btn {
        font-size: 13px;
        padding: 8px 14px;
    }

    .btn-sm {
        padding: 5px 8px;
        font-size: 12px;
    }
}

/* ===== SEARCH BAR ===== */
.search-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-bar input {
    min-width: 250px;
}

/* ===== LOADING ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

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

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
}

.toast {
    background: var(--gray-900);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

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

.toast.error {
    background: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== SEARCHABLE SELECT ===== */
.ss-container {
    position: relative;
    width: 100%;
}

.ss-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--border-radius);
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-800);
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 42px;
}

.ss-display:hover {
    border-color: var(--gray-400);
}

.ss-display-text.ss-placeholder {
    color: var(--gray-400);
}

.ss-arrow {
    font-size: 12px;
    color: var(--gray-400);
    margin-left: 8px;
    flex-shrink: 0;
}

.ss-dropdown {
    display: none;
    background: #fff;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--border-radius);
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow: hidden;
    flex-direction: column;
}

.ss-dropdown.ss-open {
    display: flex;
}

.ss-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--gray-200);
}

.ss-search {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 13px;
    outline: none;
    color: var(--gray-800);
}

.ss-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.ss-list {
    overflow-y: auto;
    max-height: 200px;
}

.ss-item {
    padding: 9px 14px;
    font-size: 14px;
    cursor: pointer;
    color: var(--gray-700);
    transition: background 0.15s;
}

.ss-item:hover {
    background: var(--gray-100);
}

.ss-item.ss-selected {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

.ss-load-more {
    padding: 9px 14px;
    text-align: center;
    font-size: 13px;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    border-top: 1px solid var(--gray-200);
}

.ss-load-more:hover {
    background: var(--gray-50);
}

.ss-no-results {
    padding: 16px 14px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-400);
}

.ss-clear-option {
    color: var(--gray-400);
    font-style: italic;
    border-bottom: 1px solid var(--gray-200);
}

/* Sortable table headers */
thead th[data-sort-dir] { position: relative; padding-right: 20px; }
thead th[data-sort-dir]::after { content: '\2195'; position: absolute; right: 6px; top: 50%; transform: translateY(-50%); opacity: 0.4; font-size: 12px; }
thead th.sort-asc::after { content: '\25B2'; opacity: 1; }
thead th.sort-desc::after { content: '\25BC'; opacity: 1; }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .main-content::before {
        left: 0;
    }
    .header {
        padding: 12px 16px;
    }
    .header h1 {
        font-size: 16px;
    }
    .header h1 #dashDateTime {
        display: block;
        font-size: 11px;
        margin-top: 2px;
    }
    .content {
        padding: 16px;
    }
    .filters {
        flex-direction: column;
        gap: 12px;
    }
    .filters .form-group {
        width: 100%;
        min-width: unset;
    }
    .panel-header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
    }
    .panel-header h2 {
        font-size: 14px;
        margin-bottom: 8px;
    }
    .panel-body {
        padding: 16px;
    }
    table th,
    table td {
        padding: 8px 12px;
        font-size: 13px;
    }
    table th {
        font-size: 11px;
    }
    .btn {
        font-size: 13px;
        padding: 8px 14px;
    }
    .btn-sm {
        font-size: 12px;
        padding: 6px 10px;
    }
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .stat-card h3 {
        font-size: 13px;
    }
    .stat-card .value {
        font-size: 24px;
    }
    .profile-name {
        display: none;
    }
    .modal {
        width: 95%;
        max-width: 95%;
        margin: 20px auto;
        max-height: calc(100vh - 40px);
    }
    .modal-body {
        max-height: calc(100vh - 200px);
    }
    .pagination {
        font-size: 13px;
        gap: 4px;
    }
    .pagination button {
        padding: 6px 10px;
        font-size: 12px;
    }
}
