/* =====================================================================
   GeoPORTAL BPTD Jabar — Modul Konektivitas Multimoda (connectivity.css)
   Simpul Multimoda, Koridor Transfer, Buffer Spasial & Indeks Aksesibilitas
   ===================================================================== */

/* =====================================================================
   1. MAP SECTION, CONTROLS & FILTER CHIPS
   ===================================================================== */
.connectivity-map-card {
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.connectivity-map-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.connectivity-map-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-map-control {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 0.375rem;
    background: #ffffff;
    color: #334155;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-map-control:hover {
    background: #f1f5f9;
    color: var(--primary);
    border-color: #cbd5e1;
}

/* Mode Filter Bar */
.mode-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.6rem 0.85rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.mode-filter-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mode-toggle-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.mode-toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    background: #ffffff;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}

.mode-toggle-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.mode-toggle-chip:hover {
    border-color: #94a3b8;
    background: #f1f5f9;
}

.mode-toggle-chip.is-checked {
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mode-toggle-chip:not(.is-checked) {
    opacity: 0.45;
    background: #f1f5f9;
    color: #94a3b8;
}

.mode-color-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: none;
}

.connectivity-map-container {
    width: 100%;
    height: 460px;
    min-height: 420px;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border);
    position: relative;
    background: #0f172a;
}

.map-status-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.9);
    color: #f8fafc;
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.map-status-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: mapSpin 0.8s linear infinite;
}

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

/* Custom Marker Styling */
.connectivity-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.4), 0 2px 5px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.connectivity-marker:hover {
    transform: scale(1.3);
    filter: brightness(1.15);
    z-index: 1000 !important;
}

.marker-terminal-a { background: #3b82f6; }
.marker-terminal-b { background: #10b981; }
.marker-uppkb      { background: #f59e0b; }
.marker-stasiun-ka { background: #8b5cf6; }
.marker-bandara    { background: #ef4444; }
.marker-pelabuhan  { background: #06b6d4; }

.marker-icon-svg {
    width: 14px;
    height: 14px;
    color: #ffffff;
    pointer-events: none;
}

/* Leaflet Popup Styling */
.leaflet-popup-content-wrapper {
    background: #ffffff !important;
    color: #0f172a !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25) !important;
    border: 1px solid #cbd5e1 !important;
}

.leaflet-popup-tip {
    background: #ffffff !important;
}

.leaflet-popup-content {
    margin: 0.75rem 0.85rem !important;
    color: #0f172a !important;
}

.popup-node-card {
    font-family: inherit;
    font-size: 0.8125rem;
}

.popup-node-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.25rem 0;
}

.popup-node-category {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 0.25rem;
    color: #ffffff;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.popup-node-location {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.popup-node-hub {
    font-size: 0.75rem;
    color: #334155;
    background: #f1f5f9;
    padding: 0.35rem 0.5rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

.popup-btn-detail {
    display: block;
    width: 100%;
    padding: 0.3rem 0;
    text-align: center;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.popup-btn-detail:hover {
    background: #1d4ed8;
}

/* =====================================================================
   2. ANALYTICS CARD & TAB SWITCHER
   ===================================================================== */
.connectivity-analytics-card {
    padding: 1.25rem;
    margin-bottom: 2rem;
}

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

.connectivity-tablist {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 0.5rem;
    padding: 0.25rem;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.connectivity-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    border: none;
    border-radius: 0.375rem;
    background: transparent;
    color: #64748b;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.connectivity-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.6);
}

.connectivity-tab-btn.is-active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.connectivity-tabpanel {
    display: block;
}

.connectivity-tabpanel[hidden] {
    display: none !important;
}

/* Toolbar & Filters */
.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 240px;
    max-width: 440px;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    max-width: 16px;
    max-height: 16px;
    color: #94a3b8;
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 38px;
    padding: 0.5rem 0.85rem 0.5rem 2.35rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
    color: var(--text-primary);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.filter-select-wrap {
    display: flex;
    align-items: center;
}

.filter-select {
    height: 38px;
    padding: 0 1.75rem 0 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.filter-select:focus {
    border-color: #38bdf8;
}

.result-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
}

/* =====================================================================
   3. TABLES (STICKY HEADER, HOVER, & BADGES)
   ===================================================================== */
.table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 520px;
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    position: relative;
    background: #ffffff;
}

.connectivity-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    text-align: left;
}

.connectivity-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid #cbd5e1;
    white-space: nowrap;
}

.connectivity-data-table thead th.th-right,
.connectivity-data-table tbody td.th-right {
    text-align: right;
}

.connectivity-data-table thead th.th-center,
.connectivity-data-table tbody td.th-center {
    text-align: center;
}

.connectivity-data-table tbody td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

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

/* Badges for categories */
.mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    white-space: nowrap;
}

.mode-badge-terminal-a { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.mode-badge-terminal-b { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.mode-badge-uppkb      { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.mode-badge-stasiun-ka { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.mode-badge-bandara    { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.mode-badge-pelabuhan  { background: #ecfeff; color: #0e7490; border: 1px solid #a5f3fc; }

/* Kemudahan badges */
.ease-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    text-align: center;
    white-space: nowrap;
}

.ease-very-high { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.ease-high      { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.ease-medium    { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* Visual Score Bar */
.score-bar-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}

.score-bar-track {
    flex: 1;
    height: 10px;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.score-bar-label {
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 48px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Rank Badge */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #475569;
}

.rank-badge-1 { background: #fef3c7; color: #b45309; }
.rank-badge-2 { background: #f1f5f9; color: #475569; }
.rank-badge-3 { background: #ffedd5; color: #c2410c; }

/* Table Action Button */
.btn-table-action {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border);
    background: #ffffff;
    color: #2563eb;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-table-action:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}

/* =====================================================================
   4. DETAIL MODAL DIALOG
   ===================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

.modal-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border-radius: 0.75rem;
    width: 90%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    z-index: 1001;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    overflow: hidden;
}

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

.modal-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.modal-badge-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.badge-score-pill {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.modal-sub {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0;
}

.modal-close-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.375rem;
    transition: color 0.15s ease, background 0.15s ease;
}

.modal-close-btn:hover {
    color: #0f172a;
    background: #e2e8f0;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    margin: 0 0 0.5rem 0;
}

.modal-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.modal-stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.modal-stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
}

.modal-stat-val {
    font-size: 0.9375rem;
    font-weight: 700;
    margin: 0;
}

.modal-stat-sub {
    font-size: 0.7rem;
    color: #94a3b8;
}

.modal-desc-text {
    font-size: 0.8125rem;
    line-height: 1.5;
    margin: 0;
    color: #334155;
}

.modal-modes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.modal-mode-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 0.375rem;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .connectivity-map-container {
        height: 360px;
    }
    .panel-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-input-wrap {
        max-width: 100%;
    }
    .modal-stats-grid {
        grid-template-columns: 1fr;
    }
}
