/* =========================================================
   Fiber Locator V2.1
   Repair Admin / Actual Repair Verification
   Production UI (Unified Premium Scale)
   ========================================================= */

: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;
    --readonly: #f1f5f9;

    --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; }

html, body { margin: 0; min-height: 100%; }

body.repair-page {
    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;
}

/* ---------- APP HEADER ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1200;
    height: 66px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, .97);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.brand-block { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 8px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--fl-blue), var(--fl-cyan)); color: #fff;
    font-size: 14px; font-weight: 900;
    box-shadow: 0 4px 12px rgba(30, 64, 175, .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); }

.app-nav {
    height: 100%;
    display: flex;
    align-items: stretch;
    gap: 8px;
}
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 16px;
    color: #64748b;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}
.nav-item:hover, .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;
}

.mode-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;
}
.mode-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fl-green); }

/* ---------- PAGE ---------- */
.page-shell {
    width: min(1500px, 100%);
    margin: 0 auto;
    padding: 24px 24px 40px;
}

.page-intro { 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-end; 
    gap: 20px; 
    margin-bottom: 24px; 
}
.eyebrow {
    margin-bottom: 6px;
    color: var(--fl-cyan); /* Mengembalikan warna biru/cyan khas */
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}
.page-title {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
    color: #0f172a;
    letter-spacing: -0.5px;
}
.page-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.hero-status {
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--fl-green-soft);
    color: #065f46;
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #a7f3d0;
    box-shadow: 0 2px 6px rgba(12, 154, 114, 0.1);
    white-space: nowrap;
}

.hero-status .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 0;
    padding: 8px 16px;
    border-radius: 999px;
    background: #ecfaf5; /* Warna latar hijau muda khas status */
    color: #0c9a72;     /* Warna teks hijau solid */
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .5px;
    box-shadow: 0 2px 6px rgba(12, 154, 114, 0.1);
}
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #0c9a72;
    box-shadow: 0 0 0 3px rgba(12, 154, 114, 0.15);
}

/* ---------- WORKSPACE ---------- */
/* Penyelarasan Tinggi Frame Kiri & Kanan */
.repair-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr);
    gap: 20px;
    align-items: stretch; /* Memaksa tinggi Map sama dengan Form */
}

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

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px 16px;
}
.card-heading { display: flex; align-items: flex-start; gap: 12px; }
.card-icon {
    width: 34px; height: 34px;
    flex: 0 0 auto;
    display: grid; place-items: center;
    border-radius: 8px;
    background: var(--fl-blue-soft);
    color: var(--fl-blue);
    font-size: 18px; font-weight: 900;
}
.card-icon.green { background: var(--fl-green-soft); color: var(--fl-green); }
.card-title { margin: 0; font-size: 16px; font-weight: 800; }
.card-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

/* ---------- MAP ---------- */
.map-card { 
    display: flex; 
    flex-direction: column; 
}
#repairMap {
    flex: 1; /* Membuat peta memanjang mengisi sisa tinggi layar */
    width: 100%;
    min-height: 560px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: #e2e8f0;
}
.leaflet-container { font-family: inherit; }

.map-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px 20px 12px;
}
.map-toolbar button {
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.map-toolbar button:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}
/* Warna Tombol Toolbar */
#btnCurrentGPS {
    background: linear-gradient(135deg, var(--fl-blue), var(--fl-cyan));
    border: none;
    color: white;
}
#btnCurrentGPS:hover { 
    filter: brightness(1.1); 
    transform: translateY(-1px); 
    box-shadow: 0 4px 10px rgba(30, 64, 175, .2);
}
#btnRefreshHistory {
    background: #ffffff;
    border: 2px solid var(--fl-blue);
    color: var(--fl-blue);
    font-weight: 800;
    transition: all 0.2s ease;
}
#btnRefreshHistory:hover { 
    background: var(--fl-blue-soft); 
    border-color: var(--fl-blue-dark); 
    color: var(--fl-blue-dark); 
}
.gps-info {
    margin: 0 20px 16px;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
}
.gps-info p { margin: 0; color: #64748b; font-size: 12px; }
.gps-info span {
    display: block;
    margin-top: 4px;
    color: #0f172a;
    font-size: 15px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 0 20px 20px;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
}
.legend div { white-space: nowrap; }

/* ---------- FORM ---------- */
.form-card { padding-bottom: 24px; }
.form-section {
    padding: 0 24px 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { margin-bottom: 0; border-bottom: 0; }
.section-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 800;
    color: #1e293b;
}
.section-title span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { min-width: 0; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 8px;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
}

input, select, textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 15px;
    outline: none;
    transition: all .2s ease;
}

input, select { height: 46px; padding: 0 14px; }
textarea { min-height: 100px; padding: 12px 14px; resize: vertical; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
    border-color: var(--fl-cyan);
    box-shadow: 0 0 0 3px rgba(8, 145, 178, .15);
}

input[readonly] {
    background: var(--readonly);
    color: #64748b;
    cursor: not-allowed;
}

input[type=number] { appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { margin: 0; }

.field-hint { margin-top: 6px; color: #94a3b8; font-size: 12px; }

/* ---------- PREDICTION REFERENCE ---------- */
.prediction-reference {
    margin: 0 24px 20px;
    padding: 16px;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    background: linear-gradient(135deg, #f0f9ff, #f8fafc);
}
.prediction-reference.hidden { display: none; }
.reference-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.reference-label {
    color: var(--fl-cyan);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.reference-status {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--fl-green-soft);
    color: #065f46;
    border: 1px solid #a7f3d0;
    font-size: 10px;
    font-weight: 800;
}
.reference-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.reference-item {
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
}
.reference-item span {
    display: block;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.reference-item strong {
    display: block;
    margin-top: 4px;
    color: #0f172a;
    font-size: 14px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

/* ---------- FEEDBACK ---------- */
.loading-box, .error-box {
    margin: 0 24px 16px;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 14px;
}
.loading-box { background: var(--fl-blue-soft); border: 1px solid #bfdbfe; color: var(--fl-blue-dark); }
.error-box { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }

/* ---------- SAVE ---------- */
.action-bar { padding: 0 24px; }
#btnSave {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--fl-blue), var(--fl-cyan));
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(30, 64, 175, .2);
    transition: all 0.2s ease;
}
#btnSave:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(30, 64, 175, .3);
    filter: brightness(1.1);
}
#btnSave:disabled {
    opacity: .6;
    cursor: wait;
    transform: none;
    filter: none;
}
.save-note {
    margin-top: 10px;
    text-align: center;
    color: #64748b;
    font-size: 13px;
}

/* ---------- FOOTER ---------- */
.app-footer {
    margin-top: 24px;
    padding: 0;
    display: flex;
    justify-content: space-between;
    color: #94a3b8;
    font-size: 13px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1100px) {
    .repair-workspace { grid-template-columns: 1fr; }
    #repairMap { height: 500px; }
}

@media (max-width: 768px) {
    .app-header { height: auto; min-height: 60px; padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
    .brand-block { min-width: 0; }
    .brand-subtitle, .mode-badge { display: none; }
    .app-nav { order: 3; width: 100%; height: 44px; overflow-x: auto; justify-content: flex-start; }
    .nav-item { padding: 0 12px; font-size: 15px; }

    .page-shell { padding: 16px 12px 32px; }
    .page-title { font-size: 24px; }

    .form-grid, .reference-grid, .gps-info { grid-template-columns: 1fr; }
    .form-group.full { grid-column: auto; }

    #repairMap { height: 420px; min-height: 340px; }
    .map-toolbar { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .brand-title { font-size: 18px; }
    input, select { height: 48px; }
    #btnSave { min-height: 52px; font-size: 16px; }
    .card-header { padding: 16px; }
    .form-section { padding-left: 16px; padding-right: 16px; }
    .prediction-reference, .action-bar, .loading-box, .error-box { margin-left: 16px; margin-right: 16px; }
}

/* accessibility */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(8, 145, 178, .3);
    outline-offset: 2px;
}