/* Base Styles */
* {
    font-family: 'Inter', sans-serif;
}

/* Sidebar Styles */
.sidebar {
    position: relative;
    z-index: 50;
    width: 15rem;
    /* w-60 = 240px - normal width */
}

.sidebar.collapsed {
    width: 4.5rem;
    /* 72px - collapsed width */
}

.sidebar.collapsed .sidebar-text {
    display: none;
}

.sidebar.collapsed .submenu {
    display: none !important;
}

.sidebar.collapsed .submenu-arrow {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-group button {
    justify-content: center;
}

/* Hover effect untuk membuka sidebar saat collapsed */
.sidebar.collapsed:hover {
    width: 15rem !important;
    /* w-60 = 240px */
    z-index: 60;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
}

.sidebar.collapsed:hover .sidebar-text {
    display: inline !important;
}

.sidebar.collapsed:hover .submenu.hidden {
    display: none !important;
}

.sidebar.collapsed:hover .submenu.open {
    display: block !important;
}

.sidebar.collapsed:hover .submenu-arrow {
    display: block !important;
}

.sidebar.collapsed:hover .nav-item {
    justify-content: flex-start !important;
    padding: 0.625rem 0.875rem !important;
}

.sidebar.collapsed:hover .nav-group button {
    justify-content: space-between !important;
}

/* Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    color: #1f2937;
    transition: all 0.2s;
    gap: 0.625rem;
    font-size: 0.875rem;
    font-weight: 700;
}

.nav-item:hover {
    background-color: #f3e8ff;
    color: #7c3aed;
}

.nav-item.active {
    background-color: #ede9fe;
    color: #6d28d9;
}

.nav-subitem {
    display: block;
    padding: 0.5rem 0.875rem;
    border-radius: 0.375rem;
    color: #374151;
    font-size: 0.8125rem;
    transition: all 0.2s;
}

.nav-subitem:hover {
    background-color: #f3e8ff;
    color: #7c3aed;
}

html.dark .nav-subitem {
    color: #94a3b8;
}

html.dark .nav-subitem:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
}

/* Page Content Loader with Glassmorphism */
#content-loader {
    position: absolute;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    /* Glassmorphism Effect */
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.1),
            rgba(255, 255, 255, 0.3));
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);

    /* Glass border & shadow */
    box-shadow:
        0 8px 32px 0 rgba(31, 38, 135, 0.15),
        inset 0 0 0 1px rgba(255, 255, 255, 0.18);

    transition: opacity 0.3s ease;
}



#content-loader.hidden {
    display: none !important;
}

/* Slim Progress Bar at the Top */
#content-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    z-index: 1001;
    width: 0;
    transition: width 0.4s ease;
}

#content-loader:not(.hidden)~#content-progress-bar {
    animation: loading-bar 2s infinite ease-in-out;
}

@keyframes loading-bar {
    0% {
        width: 0;
        left: 0;
    }

    50% {
        width: 70%;
        left: 15%;
    }

    100% {
        width: 100%;
        left: 0;
    }
}

.spinner-ring-container {
    position: relative;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner-ring {
    position: absolute;
    border: 3px solid transparent;
    border-radius: 50%;
    animation: spin linear infinite;
}

.spinner-ring:nth-child(1) {
    width: 60px;
    height: 60px;
    border-top-color: #3b82f6;
    animation-duration: 1s;
}

.spinner-ring:nth-child(2) {
    width: 44px;
    height: 44px;
    border-top-color: #8b5cf6;
    animation-duration: 0.8s;
    animation-direction: reverse;
}

.spinner-ring:nth-child(3) {
    width: 28px;
    height: 28px;
    border-top-color: #ec4899;
    animation-duration: 0.6s;
}

.spinner-text {
    margin-top: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
    letter-spacing: 0.025em;
}

.nav-subitem.active {
    color: #6d28d9;
    background-color: #ede9fe;
}

/* Submenu Animation */
.submenu {
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

/* Submenu default: hidden (tertutup) */
.submenu.hidden {
    display: none !important;
    max-height: 0;
}

.submenu.open {
    display: block !important;
    max-height: 1000px;
}

.submenu-arrow.rotated {
    transform: rotate(180deg);
}

/* Cards */
.stat-card {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

html.dark .stat-card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
}

html.dark .stat-card p.text-gray-500,
html.dark .stat-card p.text-gray-400 {
    color: #cbd5e1 !important;
}

html.dark .stat-card p.text-2xl {
    color: var(--admin-text) !important;
}

/* Broader fix for ALL content cards (Dashboard widgets, tables, etc) */
/* Global BG white fix removed from here, handled in section 8 & 9 below */

html.dark .bg-white .text-gray-500,
html.dark .bg-white .text-gray-600,
html.dark .bg-white .text-gray-700 {
    color: #cbd5e1 !important;
    /* Lighter gray for readability */
}

html.dark .bg-white .text-gray-400 {
    color: #94a3b8 !important;
}

/* Fix for ONU Status Modal (LOS/DyingGasp) */
html.dark #onu-status-modal .bg-white {
    background-color: var(--admin-card) !important;
    color: var(--admin-text) !important;
}

html.dark #onu-status-modal .bg-gray-50 {
    background-color: rgba(255, 255, 255, 0.02) !important;
    color: var(--admin-text-muted) !important;
}

html.dark #onu-status-modal table th {
    color: var(--admin-text-muted) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

html.dark #onu-status-modal table td {
    border-color: var(--admin-border) !important;
    color: var(--admin-text) !important;
}

/* Adjust Badges in Dark Mode */
html.dark #onu-status-modal .bg-red-100 {
    background-color: rgba(220, 38, 38, 0.2) !important;
    color: #fca5a5 !important;
}

html.dark #onu-status-modal .bg-green-100 {
    background-color: rgba(22, 163, 74, 0.2) !important;
    color: #86efac !important;
}

html.dark #onu-status-modal .bg-gray-100 {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #e2e8f0 !important;
}

html.dark #onu-status-modal .text-gray-900,
html.dark #onu-status-modal .text-gray-700,
html.dark #onu-status-modal .text-gray-600 {
    color: var(--admin-text) !important;
}



/* Fix for Alert Customers Section (Red Box) in Dark Mode */
html.dark #alert-customers-section {
    background: var(--admin-card) !important;
    border-color: rgba(220, 38, 38, 0.3) !important;
    box-shadow: none !important;
}

html.dark #alert-customers-section .bg-gradient-to-r {
    background: linear-gradient(to right, rgba(220, 38, 38, 0.4), rgba(225, 29, 72, 0.4)) !important;
    border-bottom: 1px solid rgba(220, 38, 38, 0.2);
}

html.dark #alert-customers-section table th {
    color: #fca5a5 !important;
    /* Lighter red for headers */
    background-color: rgba(220, 38, 38, 0.1) !important;
    border-color: rgba(220, 38, 38, 0.2) !important;
}

html.dark #alert-customers-section table td {
    color: var(--admin-text) !important;
    border-color: rgba(220, 38, 38, 0.1) !important;
}

html.dark #alert-customers-section .bg-red-50\/80 {
    background-color: rgba(220, 38, 38, 0.05) !important;
}

html.dark #alert-customers-section .bg-red-50\/50 {
    background-color: transparent !important;
}

html.dark #alert-customers-section tr:hover {
    background-color: rgba(220, 38, 38, 0.1) !important;
    /* Red-tinted hover */
}

html.dark #alert-customers-section .text-red-800 {
    color: #fca5a5 !important;
}

html.dark #alert-customers-section .divide-red-100\/50 {
    border-color: rgba(220, 38, 38, 0.1) !important;
}

html.dark #alert-view-all-container {
    background: transparent !important;
    border-top-color: rgba(220, 38, 38, 0.2) !important;
}

html.dark #alert-view-all-container button {
    color: #fca5a5 !important;
}

html.dark #alert-view-all-container button:hover {
    background: transparent !important;
    border-top-color: rgba(220, 38, 38, 0.2) !important;
}

html.dark #alert-view-all-container button {
    color: #fca5a5 !important;
}

html.dark #alert-view-all-container button:hover {
    color: #fecaca !important;
}

/* Fix for Inbox Chat List Active & Hover states */
html.dark .conversation-item:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

html.dark .conversation-item.bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.15) !important;
    /* Dark blue tint */
    border-color: rgba(59, 130, 246, 0.2) !important;
    box-shadow: none !important;
}

html.dark .conversation-item h4 {
    color: var(--admin-text) !important;
}

html.dark .conversation-item p.text-gray-600 {
    color: var(--admin-text-muted) !important;
}

html.dark .conversation-item p.text-gray-900 {
    color: #fff !important;
    /* Unread snippet */
}

html.dark .conversation-item .w-10.bg-gray-200 {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--admin-text) !important;
}

html.dark .conversation-item .text-gray-500 {
    color: #94a3b8 !important;
}

/* Fix for Chat Area in Dark Mode */
html.dark #chat-messages {
    background-color: rgba(0, 0, 0, 0.2) !important;
}

html.dark .message-content .bg-white {
    background-color: var(--admin-card) !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

html.dark .message-content .bg-blue-600 {
    background-color: #2563eb !important;
    /* Keep distinct blue but ensure contrast */
    color: #fff !important;
}

/* Fix New Message Modal Search Results */
html.dark #customer-search-results .hover\:bg-gray-50:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

html.dark #customer-search-results .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.2) !important;
    /* Avatar bg */
    color: #60a5fa !important;
}

html.dark #customer-search-results .text-gray-800 {
    color: var(--admin-text) !important;
}

html.dark h1,
html.dark h2,
html.dark h3,
html.dark h4,
html.dark h5,
html.dark h6 {
    color: var(--admin-text) !important;
}

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

.data-table th {
    background-color: #f8fafc;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.8125rem;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background-color: #dcfce7;
    color: #166534;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

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

.badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-gray {
    background-color: #f1f5f9;
    color: #475569;
}

.badge-green {
    background-color: #dcfce7;
    color: #166534;
}

.badge-red {
    background-color: #fee2e2;
    color: #991b1b;
}

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

.badge-blue {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-purple {
    background-color: #f3e8ff;
    color: #7c3aed;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.8125rem;
    transition: all 0.2s;
    gap: 0.375rem;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background-color: #2563eb;
}

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

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

.btn-danger {
    background-color: #ef4444;
    color: white;
}

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

.btn-success {
    background-color: #22c55e;
    color: white;
}

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

.btn-info {
    background-color: #06b6d4;
    color: white;
}

.btn-info:hover {
    background-color: #0891b2;
}


.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
}

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

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    background-color: white;
    cursor: pointer;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.modal.open {
    opacity: 1;
    visibility: visible;
}

.modal.open .modal-content {
    transform: scale(1);
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    max-width: calc(100% - 2rem);
    width: auto;
    min-width: 320px;
    max-height: 90vh;
    overflow-y: auto;
    margin: 1rem;
    transform: scale(0.95);
    transition: transform 0.2s;
}

html.dark .modal-content {
    background-color: var(--admin-card) !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

@media (min-width: 640px) {
    .modal-content {
        max-width: 500px;
        /* Default for normal modals */
        width: 100%;
    }

    .modal-content.max-w-md {
        max-width: 448px;
    }

    .modal-content.max-w-lg {
        max-width: 512px;
    }

    .modal-content.max-w-xl {
        max-width: 576px;
    }

    .modal-content.max-w-2xl {
        max-width: 672px;
    }

    .modal-content.max-w-4xl {
        max-width: 896px;
    }
}

/* Modal Components */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-body {
    padding: 1rem 1.25rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Supplemental Utilities (For content not processed by Tailwind) */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

.p-4 {
    padding: 1rem;
}

.border-b {
    border-bottom: 1px solid #e2e8f0;
}

.bg-gray-50 {
    background-color: #f8fafc;
}

.text-sm {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-bold {
    font-weight: 700;
}

.text-gray-500 {
    color: #64748b;
}

.w-full {
    width: 100%;
}

.sticky {
    position: sticky;
}

.top-0 {
    top: 0;
}

.bg-gray-100 {
    background-color: #f1f5f9;
}

.overflow-x-auto {
    overflow-x: auto;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.divide-y> :not([hidden])~ :not([hidden]) {
    border-top: 1px solid #e2e8f0;
}

@media (min-width: 640px) {
    .sm\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sm\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .sm\:border-l {
        border-left: 1px solid #e2e8f0;
    }

    .sm\:pl-4 {
        padding-left: 1rem;
    }

    .sm\:flex-row {
        flex-direction: row;
    }
}

@media (min-width: 768px) {
    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.font-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.text-blue-600 {
    color: #2563eb;
}

.text-green-600 {
    color: #16a34a;
}

.text-purple-600 {
    color: #7c3aed;
}

.text-orange-600 {
    color: #ea580c;
}

.text-gray-900 {
    color: #0f172a;
}

.text-red-500 {
    color: #ef4444;
}

.bg-blue-50 {
    background-color: #eff6ff;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.mr-2 {
    margin-right: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.py-8 {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.inline {
    display: inline;
}

.modal.open .modal-content {
    transform: scale(1);
}

/* Toast */
.toast {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

html.dark .toast {
    background: var(--admin-card) !important;
    color: var(--admin-text) !important;
    border: 1px solid var(--admin-border) !important;
}

html.dark .toast button:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.toast-success {
    border-left: 4px solid #22c55e;
}

.toast-error {
    border-left: 4px solid #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}

.toast-info {
    border-left: 4px solid #3b82f6;
}

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

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Spinner */
.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        width: 15rem !important;
        /* Force normal width on mobile */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sidebar.open {
        left: 0 !important;
        z-index: 1000;
    }

    /* Disable collapsed state on mobile */
    .sidebar.collapsed {
        width: 15rem !important;
    }

    .sidebar.collapsed .sidebar-text {
        display: inline !important;
    }

    .sidebar.collapsed .submenu {
        display: block !important;
    }

    .sidebar.collapsed .submenu-arrow {
        display: block !important;
    }

    /* Ensure overlay is below sidebar */
    #sidebar-overlay {
        z-index: 999 !important;
    }

    /* Ensure main content is below sidebar */
    #main-content {
        position: relative;
        z-index: 1 !important;
    }

    /* Ensure map container is below sidebar */
    #customers-map-container {
        position: relative;
        z-index: 1 !important;
    }

    /* Ensure Leaflet map is below sidebar - all panes and controls */
    #customers-map-container .leaflet-container,
    #customers-map-container .leaflet-control-container,
    #customers-map-container .leaflet-pane,
    #customers-map-container .leaflet-map-pane,
    #customers-map-container .leaflet-tile-pane,
    #customers-map-container .leaflet-overlay-pane,
    #customers-map-container .leaflet-shadow-pane,
    #customers-map-container .leaflet-marker-pane,
    #customers-map-container .leaflet-tooltip-pane,
    #customers-map-container .leaflet-popup-pane,
    #customers-map-container .leaflet-top,
    #customers-map-container .leaflet-left,
    #customers-map-container .leaflet-right,
    #customers-map-container .leaflet-popup,
    #customers-map-container .leaflet-tooltip {
        position: relative !important;
        z-index: 1 !important;
    }

    /* Fix leaflet-bottom attribution control - keep it at bottom, only adjust z-index */
    #customers-map-container .leaflet-bottom {
        position: absolute !important;
        /* Keep absolute positioning for bottom controls */
        bottom: 0 !important;
        z-index: 1 !important;
    }

    /* Ensure attribution control stays at bottom right */
    #customers-map-container .leaflet-control-attribution {
        position: relative !important;
        z-index: 1 !important;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a78bfa;
}

/* Scrollbar untuk sidebar menu */
.sidebar nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar nav::-webkit-scrollbar-track {
    background: #faf5ff;
}

.sidebar nav::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 3px;
}

.sidebar nav::-webkit-scrollbar-thumb:hover {
    background: #a78bfa;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.375rem;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Power Level Colors */
.power-good {
    color: #16a34a;
}

.power-warning {
    color: #d97706;
}

.power-critical {
    color: #dc2626;
}

/* Animated Line for ODP to Customer Connection */
@keyframes dashMove {
    0% {
        stroke-dashoffset: 0;
    }

    100% {
        stroke-dashoffset: 30;
    }
}

/* Mobile Map Container Fix */
@media (max-width: 1024px) {

    /* Ensure main content and map are below sidebar */
    #main-content {
        position: relative;
        z-index: 1;
    }

    #customers-map-container {
        height: calc(100vh - 180px) !important;
        margin-top: 0.5rem;
        position: relative;
        z-index: 1;
    }

    /* Ensure Leaflet map controls are below sidebar */
    #customers-map-container .leaflet-container {
        position: relative;
        z-index: 1;
    }

    /* When sidebar is open, ensure content doesn't overlap */
    .sidebar.open~* #main-content,
    .sidebar.open~* #customers-map-container {
        z-index: 1;
    }
}

/* =========================================
   GLOBAL MODAL & POPUP DARK MODE FIXES
   ========================================= */

/* 1. Generic Modal Backgrounds & Containers */
/* Target common modal containers if they have ID ending in -modal or -popup */
html.dark [id$="-modal"] .bg-white,
html.dark [id$="-modal"] .bg-white\/95,
html.dark [id$="-popup"] .bg-white,
html.dark [id$="-popup"] .bg-white\/95 {
    background-color: var(--admin-card) !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

/* Fix Modal Headers often using bg-gray-50 */
html.dark [id$="-modal"] .bg-gray-50,
html.dark [id$="-popup"] .bg-gray-50 {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--admin-border) !important;
}

/* Fix Modal Inputs */
html.dark [id$="-modal"] input,
html.dark [id$="-modal"] textarea,
html.dark [id$="-modal"] select,
html.dark [id$="-popup"] input,
html.dark [id$="-popup"] textarea,
html.dark [id$="-popup"] select {
    background-color: rgba(0, 0, 0, 0.2) !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

html.dark [id$="-modal"] input::placeholder,
html.dark [id$="-modal"] textarea::placeholder {
    color: var(--admin-text-muted) !important;
}

/* Fix Modal Text & Headings */
html.dark [id$="-modal"] h2,
html.dark [id$="-modal"] h3,
html.dark [id$="-popup"] h2,
html.dark [id$="-popup"] h3,
html.dark [id$="-modal"] .text-gray-900,
html.dark [id$="-modal"] .text-gray-800,
html.dark [id$="-modal"] .text-gray-700,
html.dark [id$="-popup"] .text-gray-900,
html.dark [id$="-popup"] .text-gray-800,
html.dark [id$="-popup"] .text-gray-700 {
    color: var(--admin-text) !important;
}

html.dark [id$="-modal"] .text-gray-600,
html.dark [id$="-modal"] .text-gray-500,
html.dark [id$="-popup"] .text-gray-600,
html.dark [id$="-popup"] .text-gray-500 {
    color: var(--admin-text-muted) !important;
}

/* 2. Specific Modal Fixes */

/* Login Modal Specifics */
html.dark #login-modal .bg-slate-900\/80 {
    background-color: rgba(0, 0, 0, 0.85) !important;
    /* Keep backdrop dark */
}

/* Payment Modal Specifics */
/* Payment modal often has colorful gradients, try to preserve or mute them */
html.dark #payment-modal-body .bg-gray-50 {
    background-color: transparent !important;
}

/* Media Viewer Modal */
html.dark #media-viewer-modal {
    background-color: rgba(0, 0, 0, 0.95) !important;
}

/* 3. SweetAlert2 Dark Mode Overrides */
html.dark .swal2-popup {
    background: var(--admin-card) !important;
    color: var(--admin-text) !important;
    border: 1px solid var(--admin-border) !important;
}

html.dark .swal2-title,
html.dark .swal2-content,
html.dark .swal2-html-container {
    color: var(--admin-text) !important;
}

html.dark .swal2-input,
html.dark .swal2-textarea,
html.dark .swal2-select {
    background: rgba(0, 0, 0, 0.2) !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

html.dark .swal2-close {
    color: var(--admin-text) !important;
}

html.dark .swal2-timer-progress-bar {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* 4. Dropdowns (e.g. Notification Panel) */
html.dark #notification-panel {
    background-color: var(--admin-card) !important;
    border-color: var(--admin-border) !important;
}

html.dark #notification-panel .bg-gray-50 {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--admin-border) !important;
}

html.dark #chat-header.bg-gray-50 {
    background-color: var(--admin-card) !important;
    border-bottom-color: var(--admin-border) !important;
}

/* 5. Specific Fix for "History Pemakaian Data Bulanan" (#session-history-modal) */
/* This modal has some specific inline styles and card structures */

/* Modal Content Container */
html.dark #session-history-modal .modal-content {
    background-color: var(--admin-card) !important;
    border-color: var(--admin-border) !important;
    color: var(--admin-text) !important;
}

/* Modal Header & Close Button */
html.dark #session-history-modal .modal-header {
    border-bottom-color: var(--admin-border) !important;
}

html.dark #session-history-modal .modal-header h3 {
    color: var(--admin-text) !important;
}

html.dark #session-history-modal .modal-header button {
    color: var(--admin-text-muted) !important;
}

html.dark #session-history-modal .modal-header button:hover {
    color: var(--admin-text) !important;
}

/* User Info Section (has inline style padding) */
html.dark #session-history-modal .bg-gray-50 {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-bottom-color: var(--admin-border) !important;
    border-color: var(--admin-border) !important;
}

/* User Info Labels */
html.dark #session-history-modal .text-gray-500,
html.dark #session-history-modal .text-gray-400 {
    color: var(--admin-text-muted) !important;
}

html.dark #session-history-modal .text-gray-900 {
    color: var(--admin-text) !important;
}

/* Chart Container */
html.dark #session-history-modal .border-b {
    border-bottom-color: var(--admin-border) !important;
}

html.dark #session-history-modal h4 {
    color: var(--admin-text) !important;
}

/* Summary Cards (These have inline style="background-color: white") */
html.dark #session-history-modal div[style*="background-color: white"] {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--admin-border) !important;
    box-shadow: none !important;
}

/* Statistics Text in Cards */
html.dark #session-history-modal .text-gray-900 {
    color: var(--admin-text) !important;
}

/* Table Fixes */
html.dark #session-history-modal table th {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--admin-text) !important;
    border-bottom-color: var(--admin-border) !important;
}

html.dark #session-history-modal table td {
    border-bottom-color: var(--admin-border) !important;
    color: var(--admin-text) !important;
}

html.dark #session-history-modal table tr:hover td {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Empty State */
html.dark #session-history-modal .text-center .text-gray-700 {
    color: var(--admin-text) !important;
}

/* 6. Fix for Remote Access Modal (#remote-access-modal) */
html.dark #remote-access-modal .bg-gradient-to-r {
    background: var(--admin-card) !important;
    border-color: var(--admin-border) !important;
}

html.dark #remote-access-modal .text-gray-800 {
    color: var(--admin-text) !important;
}

html.dark #remote-access-modal .text-gray-600,
html.dark #remote-access-modal .text-gray-500 {
    color: var(--admin-text-muted) !important;
}

html.dark #remote-access-modal button:hover {
    border-color: #3b82f6 !important;
    /* Blue border on hover */
    background: rgba(255, 255, 255, 0.05) !important;
}

/* 7. Fix for Add Payment Modal (#new-payment-modal) */
html.dark #new-payment-modal .bg-gray-50,
html.dark #new-payment-modal .bg-blue-50,
html.dark #new-payment-modal .bg-green-50 {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--admin-border) !important;
    color: var(--admin-text) !important;
}

html.dark #new-payment-modal .text-gray-600,
html.dark #new-payment-modal .text-gray-700 {
    color: var(--admin-text-muted) !important;
}

html.dark #new-payment-modal .text-gray-800,
html.dark #new-payment-modal .font-bold.text-gray-700 {
    color: var(--admin-text) !important;
}

/* Readonly amount input */
html.dark #new-payment-modal #new-payment-amount.bg-gray-100 {
    background-color: rgba(0, 0, 0, 0.3) !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

/* Radio buttons container */
html.dark #new-payment-modal label.border {
    border-color: var(--admin-border) !important;
}

html.dark #new-payment-modal label:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

html.dark #new-payment-modal label:has(:checked) {
    background-color: rgba(22, 163, 74, 0.15) !important;
    /* Green tint */
    border-color: #16a34a !important;
}

html.dark #new-payment-modal label:has(:checked):hover {
    background-color: rgba(22, 163, 74, 0.2) !important;
}

/* 8. Fix for Customer Forms (#add-customer-modal and shared) */
html.dark #add-customer-modal .bg-blue-50,
html.dark #add-customer-modal .bg-green-50,
html.dark #add-customer-modal .bg-gray-50,
html.dark #customer-detail-modal .bg-gray-50 {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--admin-border) !important;
    color: var(--admin-text) !important;
}

/* Specific overrides for Router info box */
html.dark #add-customer-modal .border-blue-200,
html.dark #add-customer-modal .border-green-200 {
    border-color: var(--admin-border) !important;
}

html.dark #add-customer-modal .text-green-700,
html.dark #add-customer-modal .text-blue-700 {
    color: var(--admin-text) !important;
}

/* Readonly and specific inputs */
html.dark #add-customer-modal .bg-gray-100 {
    background-color: rgba(0, 0, 0, 0.3) !important;
    color: var(--admin-text) !important;
    border-color: var(--admin-border) !important;
}

/* Photo upload preview area */
html.dark #new-photo-preview.bg-gray-50 {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--admin-border) !important;
}

/* Add-ons rows */
html.dark .addon-row.bg-gray-50 {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--admin-border) !important;
}

/* Map container */
html.dark #new-customer-map {
    border-color: var(--admin-border) !important;
    /* Maps usually handle their own tiles, but container needs border fix */
}

/* Radio/Checkbox groups */
html.dark #add-customer-modal label.border {
    border-color: var(--admin-border) !important;
}

html.dark #add-customer-modal label:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Comprehensive Dark Mode Overrides for Utility Classes */
html.dark .bg-white {
    background-color: var(--admin-card) !important;
    color: var(--admin-text) !important;
}

html.dark .modal-content .bg-white {
    background-color: var(--admin-card) !important;
}

/* Backgrounds */
html.dark .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.1) !important;
    color: #93c5fd !important;
}

html.dark .bg-green-50,
html.dark .bg-emerald-50 {
    background-color: rgba(34, 197, 94, 0.15) !important;
    color: #86efac !important;
}

html.dark .bg-red-50,
html.dark .bg-rose-50 {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #fca5a5 !important;
}

html.dark .bg-orange-50,
html.dark .bg-amber-50,
html.dark .bg-yellow-50 {
    background-color: rgba(249, 115, 22, 0.15) !important;
    color: #fdba74 !important;
}

html.dark .bg-purple-50,
html.dark .bg-indigo-50 {
    background-color: rgba(139, 92, 246, 0.15) !important;
    color: #c4b5fd !important;
}

html.dark .bg-gray-50,
html.dark .bg-gray-100 {
    background-color: var(--admin-bg) !important;
    color: var(--admin-text) !important;
}

/* Table and Modal specific backgrounds */
html.dark .bg-blue-100 {
    background-color: rgba(59, 130, 246, 0.25) !important;
}

html.dark .bg-amber-100,
html.dark .bg-yellow-100,
html.dark .bg-orange-100 {
    background-color: rgba(249, 115, 22, 0.25) !important;
}

html.dark .bg-purple-100,
html.dark .bg-indigo-100 {
    background-color: rgba(139, 92, 246, 0.25) !important;
}

/* Text Colors */
html.dark .text-gray-500,
html.dark .text-gray-600 {
    color: #9ca3af !important;
}

html.dark .text-blue-600,
html.dark .text-blue-700,
html.dark .text-blue-800,
html.dark .text-blue-900 {
    color: #60a5fa !important;
}

/* Specific contrast fix for #generate-voucher-modal */
html.dark #generate-voucher-modal .text-blue-900 {
    color: #93c5fd !important;
}

/* Specific contrast fix for #generate-voucher-modal */
html.dark #generate-voucher-modal .text-blue-900 {
    color: #93c5fd !important;
}

html.dark .text-green-600,
html.dark .text-green-700,
html.dark .text-green-800,
html.dark .text-emerald-800,
html.dark .text-emerald-900 {
    color: #4ade80 !important;
}

html.dark .text-red-500,
html.dark .text-red-600,
html.dark .text-red-700,
html.dark .text-red-800,
html.dark .text-rose-600 {
    color: #f87171 !important;
}

html.dark .text-orange-600,
html.dark .text-orange-700,
html.dark .text-orange-800,
html.dark .text-yellow-700,
html.dark .text-amber-600 {
    color: #fbbf24 !important;
}

html.dark .text-purple-600,
html.dark .text-purple-700,
html.dark .text-purple-900,
html.dark .text-indigo-600,
html.dark .text-indigo-700 {
    color: #a78bfa !important;
}

/* Borders */
html.dark .border-blue-200,
html.dark .border-blue-300 {
    border-color: rgba(59, 130, 246, 0.4) !important;
}

html.dark .border-green-200,
html.dark .border-green-300,
html.dark .border-emerald-300 {
    border-color: rgba(34, 197, 94, 0.4) !important;
}

html.dark .border-red-200,
html.dark .border-red-300,
html.dark .border-rose-200 {
    border-color: rgba(239, 68, 68, 0.4) !important;
}

html.dark .border-orange-200,
html.dark .border-orange-300,
html.dark .border-yellow-300,
html.dark .border-amber-200 {
    border-color: rgba(249, 115, 22, 0.4) !important;
}

html.dark .border-purple-200,
html.dark .border-purple-300,
html.dark .border-indigo-200,
html.dark .border-indigo-300 {
    border-color: rgba(139, 92, 246, 0.4) !important;
}

html.dark .border-gray-200,
html.dark .border-gray-300,
html.dark .border-gray-400 {
    border-color: var(--admin-border) !important;
}

/* Gradients */
html.dark .from-gray-50.to-gray-100 {
    background-image: linear-gradient(to right, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.08)) !important;
}

/* Specific component fixes */
html.dark #qr-container,
html.dark [id^="qr-"] {
    background-color: white !important;
    /* QR code usually needs white bg for scanning */
    padding: 10px;
    border-radius: 8px;
}

html.dark [id^="qr-"] * {
    color: black !important;
}

/* Active/Checked States (Tailwind has:[:checked]) */
html.dark .has-\[\:checked\]\:bg-blue-50:has(:checked) {
    background-color: rgba(59, 130, 246, 0.25) !important;
}

html.dark label:has(input[type="radio"]:checked),
html.dark label:has(input[type="checkbox"]:checked) {
    background-color: rgba(59, 130, 246, 0.2) !important;
    border-color: #3b82f6 !important;
}

/* Modal specific fixes */
html.dark .modal-header,
html.dark .modal-footer {
    border-color: var(--admin-border) !important;
    background-color: var(--admin-card) !important;
}

html.dark .form-select,
html.dark .form-input,
html.dark input.input,
html.dark select.input,
html.dark textarea.input,
html.dark select,
html.dark #generate-voucher-modal select,
html.dark #generate-voucher-modal input {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

html.dark select option {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

/* Fix text colors in form labels/descriptions */
html.dark #add-customer-modal .text-gray-500,
html.dark #add-customer-modal .text-gray-600 {
    color: var(--admin-text-muted) !important;
}

html.dark #add-customer-modal .font-medium,
html.dark #add-customer-modal .form-label {
    color: var(--admin-text) !important;
}

/* 9. Global Utility Overrides for Dark Mode */
html.dark .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.1) !important;
    color: #93c5fd !important;
    border: 1px solid rgba(59, 130, 246, 0.2) !important;
}

html.dark .bg-orange-50 {
    background-color: rgba(249, 115, 22, 0.1) !important;
    color: #fdba74 !important;
    border: 1px solid rgba(249, 115, 22, 0.2) !important;
}

html.dark .bg-green-50 {
    background-color: rgba(34, 197, 94, 0.1) !important;
    color: #86efac !important;
    border: 1px solid rgba(34, 197, 94, 0.2) !important;
}

/* Specific Modal Context Fixes */
html.dark [id$="-modal"] .text-gray-600,
html.dark [id$="-modal"] .text-gray-700,
html.dark [id$="-modal"] .text-gray-500 {
    color: var(--admin-text-muted) !important;
}

html.dark #change-ssid-modal .bg-white,
html.dark #customer-detail-modal .bg-white,
html.dark .bg-white {
    background-color: var(--admin-card) !important;
    color: var(--admin-text) !important;
}

html.dark #change-ssid-modal .border-b,
html.dark #change-ssid-modal .border-t,
html.dark #customer-detail-modal .border-b,
html.dark #customer-detail-modal .border-t {
    border-color: var(--admin-border) !important;
}

html.dark #customer-detail-modal .bg-white.sticky {
    background-color: var(--admin-card) !important;
}

/* Form refinement for dark mode */
html.dark .form-label {
    color: var(--admin-text) !important;
}

html.dark .text-gray-500,
html.dark .text-gray-400 {
    color: var(--admin-text-muted) !important;
}

html.dark .form-input::placeholder {
    color: var(--admin-text-muted) !important;
    opacity: 0.7;
}

/* 10. Traffic & Session History Refinements */
.traffic-stat-card {
    background-color: white;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

html.dark .traffic-stat-card {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--admin-border) !important;
    box-shadow: none !important;
}

html.dark .traffic-stat-card p {
    color: var(--admin-text) !important;
}

/* Fix for session history table header in dark mode */
html.dark #session-history-modal thead.bg-gray-100,
html.dark thead.bg-gray-100.sticky {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Custom WhatsApp-style Audio Player */
.wa-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #f0fdf4;
    border-radius: 12px;
    min-width: 200px;
    max-width: 280px;
    border: 1px solid #dcfce7;
}

html.dark .wa-audio-player {
    background: #064e3b;
    /* Deep green */
    border-color: #065f46;
}

.wa-audio-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #25D366;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.wa-audio-btn:hover {
    background: #128C7E;
    transform: scale(1.05);
}

.wa-audio-btn:active {
    transform: scale(0.95);
}

.wa-audio-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wa-audio-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

html.dark .wa-audio-progress-bar {
    background: rgba(255, 255, 255, 0.1);
}

.wa-audio-progress-fill {
    height: 100%;
    background: #25D366;
    width: 0%;
}

.wa-audio-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wa-audio-time {
    font-size: 10px;
    color: #666;
    font-weight: 500;
}

html.dark .wa-audio-time {
    color: #94a3b8;
}

.wa-audio-ptt-icon {
    color: #25D366;
    opacity: 0.7;
}

.wa-audio-download {
    color: #25D366;
    opacity: 0.7;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-audio-download:hover {
    opacity: 1;
    color: #128C7E;
    transform: scale(1.1);
}