/* =========================================================
   Fiber Locator V2.1
   Technician Workspace (Unified Production UI)
   ========================================================= */

:root {
    --fl-blue: #1e40af;
    --fl-blue-dark: #1e3a8a;
    --fl-blue-soft: #eff6ff;
    --fl-cyan: #0891b2;
    --fl-green: #059669;
    --fl-green-soft: #d1fae5;
    --fl-red: #dc2626;
    --fl-orange: #d97706;

    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --surface: #ffffff;
    --page: #f8fafc;

    --shadow-sm: 0 4px 6px -1px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(15, 23, 42, 0.08);
    --radius: 12px;
}

* { box-sizing: border-box; }

body.prediction-page {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px; 
    line-height: 1.5;
}

/* =========================================================
   HEADER (Disamakan dengan Report Admin)
   ========================================================= */
.prediction-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 66px; /* Sama dengan admin */
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.97);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--fl-blue), var(--fl-cyan));
    color: white;
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.25);
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--fl-blue-dark);
}

.brand-subtitle {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

.prediction-nav {
    display: flex;
    align-items: stretch;
    height: 100%;
    gap: 8px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    color: #64748b;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}
.nav-item:hover { color: var(--fl-blue); }
.nav-item.active { color: var(--fl-blue); }
.nav-item.active::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 0;
    height: 3px;
    background: var(--fl-blue);
    border-radius: 3px 3px 0 0;
}

.production-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid #a7f3d0;
    border-radius: 999px;
    background: var(--fl-green-soft);
    color: #065f46;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .5px;
}
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--fl-green);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

/* =========================================================
   WORKSPACE & PANELS
   ========================================================= */
.prediction-workspace {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 20px;
    padding: 24px;
    max-width: 1480px;
    margin: 0 auto;
}

.panel {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.input-panel { padding: 24px; }
.result-panel { padding: 24px; min-height: 320px; }

.panel-heading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
}

.panel-icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--fl-blue-soft);
    color: var(--fl-blue);
    font-size: 18px;
    font-weight: 900;
}
.result-icon {
    background: var(--fl-green-soft);
    color: var(--fl-green);
}

.panel-heading h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}
.panel-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

/* =========================================================
   FORM INPUTS
   ========================================================= */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
}
.unit-label { color: #94a3b8; font-weight: 600; }

.form-group select,
.form-group input {
    width: 100%;
    height: 46px; 
    padding: 0 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 15px; 
    outline: none;
    transition: all .2s ease;
}
.form-group select:focus,
.form-group input:focus {
    border-color: var(--fl-cyan);
    box-shadow: 0 0 0 3px rgba(8,145,178,0.15);
}

.calculate-button {
    width: 100%;
    height: 48px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--fl-blue), var(--fl-cyan));
    color: white;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(30, 64, 175, 0.2);
    transition: transform .2s ease, box-shadow .2s ease;
}
.calculate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(30, 64, 175, 0.3);
    filter: brightness(1.1);
}
.calculate-button:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}
.button-arrow { font-size: 16px; }

.input-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569;
    font-size: 13px;
    line-height: 1.5;
}

/* =========================================================
   ERROR & EMPTY STATE
   ========================================================= */
.error-box {
    margin-top: 16px;
    padding: 12px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 13px;
    line-height: 1.5;
}

.empty-state {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #f1f5f9;
    color: var(--muted);
}
.empty-icon { margin-bottom: 8px; color: #94a3b8; font-size: 28px; }
.empty-state strong { color: #334155; font-size: 16px; }
.empty-state span { margin-top: 6px; font-size: 13px; }

/* =========================================================
   TECHNICIAN RESULT
   ========================================================= */
.tech-result {
    display: grid;
    gap: 16px;
}

.prediction-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.prediction-label {
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.prediction-meter {
    margin-top: 8px;
    color: #34d399;
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
}
.prediction-caption { margin-top: 8px; color: #64748b; font-size: 13px; }

.confidence-box {
    min-width: 120px;
    padding: 14px;
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: 10px;
    background: rgba(52, 211, 153, 0.05);
    text-align: center;
}
.confidence-label {
    display: block;
    color: #6ee7b7;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.confidence-value {
    display: block;
    margin-top: 6px;
    color: #34d399;
    font-size: 20px;
    font-weight: 800;
}

.field-grid, .asset-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.field-card, .asset-mini {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}
.field-card .label, .asset-mini .asset-type {
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.field-card .value, .asset-mini .asset-name {
    margin-top: 6px;
    color: #0f172a;
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.asset-mini .asset-distance { margin-top: 4px; color: var(--fl-blue); font-size: 13px; font-weight: 600; }

/* =========================================================
   RESULT ACTIONS (Tombol Eksekusi Lapangan)
   ========================================================= */
.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.result-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1; /* Membuat tombol meregang penuh dan sama besar */
    min-width: 160px;
    height: 48px; /* Lebih besar agar mudah di-tap di HP */
    padding: 0 16px;
    border-radius: 8px;
    border: none;
    text-decoration: none;
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

/* Tombol MAP: Hijau Navigasi Mencolok */
.result-action.primary {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    box-shadow: 0 6px 16px rgba(5, 150, 105, 0.25);
}
.result-action.primary:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.35);
}

/* Tombol FIELD VERIFICATION: Oranye/Amber Perhatian Ekstra */
.result-action.secondary {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    color: white;
    box-shadow: 0 6px 16px rgba(217, 119, 6, 0.25);
}
.result-action.secondary:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(217, 119, 6, 0.35);
}

.coordinate-line { color: #64748b; font-size: 13px; margin-top: 4px; }


/* =========================================================
   MAP
   ========================================================= */
.map-panel {
    margin: 0 auto 24px;
    max-width: 1432px; /* Disesuaikan dengan grid workspace */
    width: calc(100% - 48px);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.map-heading {
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
}
.map-heading h2 { margin: 0; font-size: 16px; font-weight: 800; }
.map-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.map-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 8px; height: 8px; display: inline-block; border-radius: 50%; }

.legend-route { background: #155eef; }
.legend-fault { background: #e5484d; }
.legend-history { background: #e69a21; }
.legend-asset { background: #10a879; }

#fiberMap { width: 100%; height: 560px; }
.leaflet-container { font-family: Inter, system-ui, sans-serif; }

.fault-popup { min-width: 200px; }
.fault-popup .popup-title { color: #dc2626; font-size: 13px; font-weight: 800; }
.fault-popup .popup-meter { margin-top: 6px; font-size: 16px; font-weight: 800; }


/* =========================================================
   FOOTER
   ========================================================= */
.prediction-footer {
    max-width: 1480px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    padding: 12px 24px 24px;
    color: #94a3b8;
    font-size: 13px;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1100px) {
    .prediction-workspace { grid-template-columns: 1fr; }
    .input-panel { position: static; }
}

@media (max-width: 768px) {
    .prediction-header {
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 12px;
    }
    .brand-subtitle, .production-badge { display: none; }
    .prediction-nav { order: 3; width: 100%; height: 44px; overflow-x: auto; margin-left: 0; }
    .nav-item { padding: 0 12px; }
    
    .prediction-workspace { padding: 16px; gap: 16px; width: 100%; }
    .map-panel { width: calc(100% - 32px); margin: 0 16px 16px; }
    
    .map-heading { flex-direction: column; align-items: flex-start; gap: 12px; }
    .map-legend { flex-wrap: wrap; }
    
    .prediction-hero { flex-direction: column; align-items: flex-start; gap: 16px; }
    .confidence-box { width: 100%; }
    
    .field-grid, .asset-strip { grid-template-columns: 1fr; }
    #fiberMap { height: 420px; }
}

@media (max-width: 520px) {
    .form-group select, .form-group input { height: 48px; }
    .calculate-button { height: 52px; font-size: 16px; }
    .result-action { flex: 1; min-width: 140px; }
}