/* =====================================================================
   GeoPORTAL BPTD Jabar — Modul Terminal Penumpang (PHASE 15C)
   CSS khusus halaman /command-center/terminal/
   Mewarisi design tokens & shell dari ../command-center.css
   ===================================================================== */

/* ---------- Section Header & Headings ---------- */
.card-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ---------- Top 5 Ranking & Map CTA Grid ---------- */
.ranking-cta-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    min-width: 0;
}

/* --- Ranking Card --- */
.ranking-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.ranking-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    min-width: 0;
}

.ranking-item:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.ranking-num {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ranking-num-1 {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.ranking-num-2 {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.ranking-num-3 {
    background: #ffedd5;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.ranking-num-other {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.ranking-info {
    flex: 1;
    min-width: 0;
}

.ranking-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-stats {
    text-align: right;
    white-space: nowrap;
    padding: 0 0.5rem;
    flex: none;
}

.ranking-val {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--blue-700);
    font-variant-numeric: tabular-nums;
}

.ranking-unit {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
}

.btn-ranking-detail {
    min-height: 44px;
    min-width: 44px;
    padding: 0.4rem 0.85rem;
    background: #eff6ff;
    color: var(--blue-700);
    border: 1px solid #bfdbfe;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    transition: all 0.15s ease;
}

.btn-ranking-detail:hover {
    background: #dbeafe;
    border-color: var(--blue-500);
}

.btn-ranking-detail:focus {
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

.ranking-loading,
.ranking-empty {
    padding: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: #f8fafc;
    border-radius: 0.5rem;
    border: 1px dashed var(--border);
}

/* --- Map CTA Card --- */
.map-cta-card {
    background: linear-gradient(145deg, #0a1526 0%, #0f1f38 100%);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.map-cta-icon-wrap {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 64px;
    height: 64px;
    color: rgba(255, 255, 255, 0.08);
}

.map-cta-icon-wrap .icon-lg {
    width: 100%;
    height: 100%;
}

.map-cta-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.4rem;
}

.map-cta-desc {
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.map-cta-note {
    font-size: 0.75rem;
    color: #94a3b8;
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    line-height: 1.4;
    margin-bottom: 1.25rem;
}

.map-cta-note .icon-sm {
    flex: none;
    margin-top: 1px;
}

.btn-map-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.6rem 1.25rem;
    background: var(--blue-500);
    color: #ffffff;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-map-cta:hover {
    background: #254db3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.btn-map-cta:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Directory Section ---------- */
.directory-card {
    padding: 1.5rem;
    min-width: 0;
    overflow: hidden;
    max-width: 100%;
}

.directory-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.result-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    background: #f1f5f9;
    padding: 0.3rem 0.65rem;
    border-radius: 0.375rem;
    white-space: nowrap;
}

/* --- Filter Bar --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.filter-search-wrap {
    flex: 1 1 220px;
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    min-height: 44px;
    padding: 0.5rem 0.75rem 0.5rem 2.4rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.search-input:focus {
    border-color: var(--blue-500);
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

.filter-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.select-wrap {
    position: relative;
    min-width: 0;
}

.filter-select {
    min-height: 44px;
    max-width: 100%;
    padding: 0.5rem 1.75rem 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
}

.filter-select:focus {
    border-color: var(--blue-500);
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

.btn-reset-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-reset-filter:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-reset-filter:focus {
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

/* --- Directory Table --- */
.table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
    box-sizing: border-box;
}

.table-wrap:focus {
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

.terminal-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.terminal-table th {
    padding: 0.75rem 1rem;
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.terminal-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

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

.th-code { width: 90px; }
.th-type { width: 90px; }
.th-num { text-align: right; }
.th-action { width: 100px; text-align: center; }

.td-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
}

.td-zero {
    color: var(--text-soft);
    font-weight: 400;
}

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

.btn-table-detail {
    min-height: 44px;
    min-width: 44px;
    padding: 0.4rem 0.85rem;
    border: 1px solid #bfdbfe;
    border-radius: 0.375rem;
    background: #eff6ff;
    color: var(--blue-700);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-table-detail:hover {
    background: #dbeafe;
    border-color: var(--blue-500);
}

.btn-table-detail:focus {
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

/* --- Badges --- */
.badge-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.45rem;
    border-radius: 0.25rem;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
}

.badge-type {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    display: inline-block;
}

.badge-type-a {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-type-b {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.badge-type-c {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.badge-type-other {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

/* --- Table States --- */
.table-state-box {
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: #f8fafc;
    border-radius: 0.5rem;
    border: 1px dashed var(--border);
    margin-top: 0.75rem;
}

.table-state-box .state-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    margin: 0.5rem 0 0.25rem;
}

.table-state-box .state-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.table-state-error {
    background: #fef2f2;
    border-color: #fecaca;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--blue-700);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 0.75rem;
}

.loading-spinner-sm {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #cbd5e1;
    border-top-color: var(--blue-700);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.btn-primary-sm {
    min-height: 44px;
    padding: 0.5rem 1rem;
    background: var(--blue-700);
    color: #ffffff;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary-sm:hover {
    background: var(--blue-500);
}

.btn-primary-sm:focus {
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

/* ---------- Terminal Detail Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 13, 25, 0.7);
    backdrop-filter: blur(4px);
    z-index: 998;
}

.modal-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92%;
    max-width: 740px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--card);
    border-radius: 0.85rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    z-index: 999;
    display: flex;
    flex-direction: column;
}

.modal-header {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    z-index: 2;
}

.modal-title-group {
    flex: 1;
    min-width: 0;
}

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    line-height: 1.3;
}

.modal-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.modal-close-btn {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-close-btn:hover {
    background: #f1f5f9;
    color: var(--text);
}

.modal-close-btn:focus {
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- Modal Loading & Error --- */
.modal-loading-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    color: var(--blue-700);
}

.modal-error-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
}

.modal-error-text {
    flex: 1;
}

.modal-error-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #991b1b;
}

.modal-error-sub {
    font-size: 0.75rem;
    color: #b91c1c;
}

.modal-retry-btn {
    min-height: 44px;
    padding: 0.4rem 0.85rem;
    background: #ef4444;
    color: #ffffff;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.modal-retry-btn:hover {
    background: #dc2626;
}

.modal-retry-btn:focus {
    outline: 2px solid #b91c1c;
    outline-offset: 1px;
}

/* --- Modal Photo --- */
.modal-photo-container {
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #000000;
}

.modal-photo-img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    display: block;
}

.modal-photo-caption {
    padding: 0.4rem 0.75rem;
    background: #f8fafc;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin: 0;
}

/* --- Modal Section --- */
.modal-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.modal-section-badge {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
}

/* --- Modal Stats Grid --- */
.modal-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.modal-stat-card {
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.modal-stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    display: block;
}

.modal-stat-val {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--blue-700);
    margin: 0.25rem 0;
    font-variant-numeric: tabular-nums;
}

.modal-stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    line-height: 1.4;
}

/* --- Trend Chart --- */
.trend-container {
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.trend-bars-wrap {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    height: 150px;
    padding-top: 1.5rem;
    border-bottom: 1px solid #cbd5e1;
    position: relative;
}

.trend-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    position: relative;
}

.trend-bar-fill {
    width: 100%;
    max-width: 28px;
    background: var(--blue-500);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: height 0.3s ease;
}

.trend-bar-fill-zero {
    background: #cbd5e1;
    height: 2px !important;
}

.trend-bar-val {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.trend-months-wrap {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.trend-month-label {
    flex: 1;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.trend-empty-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem 0;
}

/* --- Modal Info Grid (DL) --- */
.modal-info-dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1.25rem;
    margin: 0;
}

.modal-info-row-full {
    grid-column: 1 / -1;
}

.modal-dt {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.15rem;
}

.modal-dd {
    font-size: 0.875rem;
    color: var(--text);
    margin: 0;
    line-height: 1.4;
    word-break: break-word;
}

/* --- Modal Footer --- */
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    background: #f8fafc;
    border-bottom-left-radius: 0.85rem;
    border-bottom-right-radius: 0.85rem;
}

.btn-secondary {
    min-height: 44px;
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #ffffff;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

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

.btn-secondary:focus {
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

/* ---------- Responsive Adjustments ---------- */
@media (max-width: 1024px) {
    .ranking-cta-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .ranking-item {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .ranking-info {
        flex: 1 1 calc(100% - 150px);
        min-width: 0;
    }

    .ranking-stats {
        padding: 0;
        margin-left: auto;
    }

    .btn-ranking-detail {
        width: 100%;
        margin-top: 0.2rem;
    }

    .directory-card {
        padding: 1rem;
    }

    .ranking-card, .map-cta-card {
        padding: 1.25rem 1rem;
    }

    .modal-stats-grid {
        grid-template-columns: 1fr;
    }

    .modal-info-dl {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
    }

    .filter-search-wrap {
        flex: 1 1 auto;
        width: 100%;
    }

    .filter-controls {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .select-wrap {
        width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    .btn-reset-filter {
        justify-content: center;
        width: 100%;
    }

    .modal-dialog {
        width: 95%;
        max-height: 92vh;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}

@media (max-width: 540px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }
}
