/* ============================================================
   Fiber Splice Map — Global Styles
   ============================================================ */

:root {
  --bg:         #0f172a;
  --bg-2:       #1e293b;
  --bg-3:       #334155;
  --border:     #334155;
  --text:       #f1f5f9;
  --text-muted: #94a3b8;
  --accent:     #3b82f6;
  --accent-h:   #2563eb;
  --danger:     #ef4444;
  --success:    #22c55e;
  --warning:    #f59e0b;
  --radius:     8px;
  --sidebar-w:  220px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif;
             background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Utility ── */
.hidden { display: none !important; }
.link { cursor: pointer; color: var(--accent); text-decoration: underline; }
.hint { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
code { background: var(--bg-3); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ── Login ── */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 48px 40px; width: 380px;
  box-shadow: var(--shadow); text-align: center;
}
.login-logo { font-size: 48px; color: var(--accent); margin-bottom: 8px; }
.login-card h1 { margin-bottom: 32px; font-size: 22px; }

/* ── App Layout ── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 20px 16px; font-size: 18px; font-weight: 700;
  color: var(--accent); letter-spacing: .5px;
}
.sidebar-logo span { font-size: 14px; color: var(--text); font-weight: 500; }
.sidebar-nav { list-style: none; flex: 1; padding: 8px 0; }
.sidebar-nav li {
  padding: 10px 16px; cursor: pointer; border-radius: 0;
  transition: background .15s; color: var(--text-muted); font-size: 13px;
}
.sidebar-nav li:hover { background: var(--bg-3); color: var(--text); }
.sidebar-nav li.active { background: var(--accent); color: #fff; }
.sidebar-footer {
  padding: 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
#user-badge { font-size: 12px; color: var(--text-muted); flex: 1; }

/* ── Main content ── */
.main-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.tab-panel { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.tab-panel.active { display: flex; }

/* ── Panel header ── */
.panel-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-header h2, .panel-header h3 { font-size: 16px; flex: 1; }
.panel-sub-header { background: var(--bg-2); }
.panel-actions { display: flex; gap: 8px; align-items: center; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 16px; border-radius: var(--radius);
  border: none; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost   { background: var(--bg-3); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: #475569; }
.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; color: var(--text-muted); }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
input[type=text], input[type=password], input[type=email],
input[type=number], select, textarea {
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; font-size: 13px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}
textarea { min-height: 80px; resize: vertical; }
.select-sm { padding: 5px 10px; font-size: 12px; width: auto; }
.error-msg { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* ── Tables ── */
#cables-table-wrap, #strands-table-wrap, #enclosures-table-wrap,
#splices-table-wrap, #networks-table-wrap, #users-table-wrap {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
}
#cables-table-wrap > div, #strands-table-wrap > div, #enclosures-table-wrap > div,
#splices-table-wrap > div, #networks-table-wrap > div, #users-table-wrap > div {
  display: contents;
}
#cable-detail {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.table-wrap { overflow: auto; flex: 1; min-height: 0; }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--bg-2); color: var(--text-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 12px; text-align: left; position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--border);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg-2); }
.table-actions { display: flex; gap: 6px; }

/* ── Color swatch ── */
.swatch {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 3px; border: 1px solid rgba(255,255,255,.15);
  vertical-align: middle; margin-right: 4px;
}
.network-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.07); border-radius: 4px;
  padding: 2px 8px; font-size: 12px;
}

/* ── Status badges ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.badge-live    { background: rgba(34,197,94,.15);  color: #22c55e; }
.badge-dark    { background: rgba(148,163,184,.1);  color: #94a3b8; }
.badge-inside  { background: rgba(59,130,246,.15);  color: #3b82f6; }
.badge-outside { background: rgba(245,158,11,.15);  color: #f59e0b; }
.badge-trunk   { background: rgba(168,85,247,.15);  color: #a855f7; margin-left: 6px; }

/* ── Diagram ── */
#topology-diagram {
  flex: 1; background: var(--bg);
  border: none;
}
.diagram-tooltip {
  position: absolute; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; font-size: 12px; pointer-events: none;
  max-width: 260px; box-shadow: var(--shadow); z-index: 100;
}

/* ── Geo Map ── */
#geo-map { flex: 1; }

/* ── Trace ── */
.trace-controls {
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#trace-result { flex: 1; overflow: auto; padding: 20px; }

.trace-path {
  display: flex; flex-direction: column; gap: 0;
}
.trace-origin, .trace-destination {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
}
.trace-hop {
  display: flex; align-items: stretch; gap: 0;
}
.trace-hop-line {
  width: 2px; background: var(--accent); margin: 0 18px;
  min-height: 40px; flex-shrink: 0;
}
.trace-splice-box {
  background: var(--bg-2); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 12px 16px;
  flex: 1; margin: 4px 0;
}
.trace-splice-box .enclosure-name { color: var(--accent); font-weight: 600; }
.trace-strand-label { font-size: 12px; color: var(--text-muted); }
.trace-branch {
  margin-left: 40px; border-left: 2px dashed var(--warning);
  padding-left: 20px;
}
.trace-empty { color: var(--text-muted); padding: 40px; text-align: center; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); width: 480px; max-width: 95vw;
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-lg { width: 680px; }
.modal-header {
  display: flex; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-header h3 { flex: 1; font-size: 16px; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 18px; padding: 2px 6px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ── Import drop zone ── */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px; text-align: center; color: var(--text-muted);
  cursor: pointer; transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent); background: rgba(59,130,246,.05);
}
#import-preview-table { overflow-x: auto; max-height: 300px; }

/* ── Strand color dots ── */
.fiber-dot {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.2);
  vertical-align: middle;
}

/* ── Responsive tweaks ── */
@media (max-width: 768px) {
  .sidebar { width: 52px; }
  .sidebar-logo span, .sidebar-nav li { overflow: hidden; }
  .sidebar-nav li { font-size: 18px; padding: 12px; }
}
