/* ==========================================================================
   FIBERHOME MASTER — MODERN GLASSMORPHISM DESIGN SYSTEM
   Mobile-First, Field-Technician Friendly & Ultra-Clean NOC Dashboard
   ========================================================================== */

:root {
  /* Color Palette - Dark Default */
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-surface-elevated: #1a2234;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.95);
  --bg-modal: #111827;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(6, 182, 212, 0.5);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #06b6d4;
  --primary-hover: #0891b2;
  --primary-glow: rgba(6, 182, 212, 0.25);

  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;

  /* Optical Signal & Health Thresholds */
  --signal-good: #10b981;
  --signal-good-bg: rgba(16, 185, 129, 0.15);
  --signal-warn: #f59e0b;
  --signal-warn-bg: rgba(245, 158, 11, 0.15);
  --signal-danger: #ef4444;
  --signal-danger-bg: rgba(239, 68, 68, 0.15);
  --signal-offline: #6b7280;
  --signal-offline-bg: rgba(107, 114, 128, 0.15);

  /* Shadows & Blur */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --glass-blur: blur(14px);

  /* Spacing & Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

[data-theme="light"] {
  /* Light ala Google (Material): putih bersih, Google Blue, abu Material */
  --bg-app: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8f9fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f3f4;
  --bg-modal: #ffffff;

  --border-subtle: #dadce0;
  --border-focus: rgba(26, 115, 232, 0.5);

  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-muted: #80868b;

  --primary: #1a73e8;
  --primary-hover: #1765cc;
  --primary-glow: rgba(26, 115, 232, 0.18);

  --accent-blue: #1a73e8;
  --accent-purple: #8430ce;

  /* Signal thresholds (Material greens/reds agar terbaca di putih) */
  --signal-good: #188038;
  --signal-good-bg: rgba(24, 128, 56, 0.12);
  --signal-warn: #b06000;
  --signal-warn-bg: rgba(234, 134, 0, 0.12);
  --signal-danger: #d93025;
  --signal-danger-bg: rgba(217, 48, 37, 0.10);
  --signal-offline: #5f6368;
  --signal-offline-bg: rgba(95, 99, 104, 0.10);

  --shadow-sm: 0 1px 2px 0 rgba(60, 64, 67, .12), 0 1px 3px 1px rgba(60, 64, 67, .08);
  --shadow-md: 0 1px 3px 0 rgba(60, 64, 67, .15), 0 4px 8px 3px rgba(60, 64, 67, .08);
  --shadow-lg: 0 4px 12px 3px rgba(60, 64, 67, .12), 0 1px 3px rgba(60, 64, 67, .15);
  --glass-blur: blur(0px);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.mono {
  font-family: var(--font-mono);
}

/* App Shell Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Navigation (Desktop only) */
.sidebar {
  width: 250px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  flex-shrink: 0;
  transition: width 0.3s ease;
}

.sidebar-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 0 12px var(--primary-glow);
}

.brand-info h1 {
  font-size: 15px;
  line-height: 1.2;
}

.brand-info span {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(6, 182, 212, 0.3);
  font-weight: 600;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--signal-warn-bg);
  color: var(--signal-warn);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: 74px; /* Space for mobile bottom bar */
}

@media (min-width: 768px) {
  .main-content {
    padding-bottom: 24px;
  }
}

.content-body {
  padding: 20px;
  max-width: 1360px;
  margin: 0 auto;
  width: 100%;
}

/* Top Navigation Bar */
.topbar {
  min-height: 56px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 8px;
}

/* OLT Selector & Status Pill */
.olt-switcher-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
}

.olt-select-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.olt-select-box:focus {
  border-color: var(--primary);
}

.safety-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.safety-pill.dev {
  background: var(--signal-good-bg);
  color: var(--signal-good);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.safety-pill.prod {
  background: var(--signal-danger-bg);
  color: var(--signal-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.pulsing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* Mobile Bottom Navigation (Visible on smartphones) */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 58px;
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
}

@media (min-width: 768px) {
  .mobile-nav {
    display: none;
  }
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  padding: 6px 4px;
  transition: all 0.2s ease;
  flex: 1;
  min-height: 54px;
}

.mobile-nav-item:active {
  transform: scale(0.92);
}

.mobile-nav-item.active {
  color: var(--primary);
  font-weight: 700;
}

.mobile-nav-item svg {
  width: 20px;
  height: 20px;
}

/* Responsive Breakpoints for Mobile */
@media (max-width: 767px) {
  .sidebar {
    display: none;
  }
  .content-body {
    padding: 12px 10px;
  }
  .topbar {
    padding: 6px 12px;
    min-height: 52px;
  }
  .olt-select-box {
    max-width: 155px;
    font-size: 12px;
    padding: 6px 8px;
  }
  .olt-switcher-wrapper label {
    display: none;
  }
}

/* Glass Cards & Containers */
.card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  width: 100%;
  margin-bottom: 14px;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
  }
  .stat-card {
    padding: 10px 12px !important;
    gap: 8px !important;
  }
  .stat-icon-wrapper {
    width: 34px !important;
    height: 34px !important;
    border-radius: var(--radius-sm) !important;
  }
  .stat-icon-wrapper svg {
    width: 18px !important;
    height: 18px !important;
  }
  .stat-val {
    font-size: 18px !important;
  }
  .stat-label {
    font-size: 10px !important;
    line-height: 1.2 !important;
  }
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  margin-bottom: 0;
}

.stat-icon-wrapper {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-val {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s ease;
  outline: none;
  min-height: 38px;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent-blue));
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-danger {
  background: var(--signal-danger-bg);
  color: var(--signal-danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 5px 9px;
  font-size: 12px;
  min-height: 32px;
}

.btn-icon-only {
  padding: 7px;
  border-radius: var(--radius-md);
  min-width: 36px;
  min-height: 36px;
}

@media (max-width: 480px) {
  .btn {
    padding: 7px 11px;
    font-size: 12px;
  }
}

/* Optical dBm Signal Badges */
.badge-signal {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.badge-signal.good {
  background: var(--signal-good-bg);
  color: var(--signal-good);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-signal.warning {
  background: var(--signal-warn-bg);
  color: var(--signal-warn);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-signal.critical {
  background: var(--signal-danger-bg);
  color: var(--signal-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-signal.offline {
  background: var(--signal-offline-bg);
  color: var(--signal-offline);
  border: 1px solid rgba(107, 114, 128, 0.3);
}

/* Signal Meter Bar */
.signal-meter {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.signal-meter-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Tables with Touch-friendly Scroll & Sticky Headers */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  margin: 0;
  position: relative;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  min-width: 540px;
}

.data-table th {
  padding: 10px 12px;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

@media (max-width: 767px) {
  .data-table th, .data-table td {
    padding: 9px 8px;
    font-size: 12px;
  }
}

/* Forms & Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  width: 100%;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 8px 11px;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
  min-height: 40px;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* Multi-Step Save Progress Stepper */
.progress-stepper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.step-item.active {
  color: var(--primary);
  font-weight: 600;
}

.step-item.done {
  color: var(--signal-good);
}

.step-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.step-item.active .step-circle {
  background: var(--primary-glow);
  animation: pulseStep 1.5s infinite;
}

@keyframes pulseStep {
  0% { box-shadow: 0 0 0 0 var(--primary-glow); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Modals (Bottom Sheet on Smartphones) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-modal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  transform: translateY(15px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

@media (max-width: 600px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal-card {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 18px 18px 0 0;
    padding: 16px 14px 28px;
    border-bottom: none;
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  max-width: calc(100vw - 24px);
}

@media (max-width: 600px) {
  .toast-container {
    left: 10px;
    right: 10px;
    top: 8px;
  }
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 250px;
  animation: slideInToast 0.3s ease;
}

@keyframes slideInToast {
  from { transform: translateY(-16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast.success { border-left: 4px solid var(--signal-good); }
.toast.error { border-left: 4px solid var(--signal-danger); }
.toast.warning { border-left: 4px solid var(--signal-warn); }
.toast.info { border-left: 4px solid var(--primary); }

/* Card PON Grid Visualizer */
.pon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 6px;
}

.pon-port-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 3px;
  text-align: center;
  transition: all 0.15s ease;
  cursor: pointer;
}

.pon-port-box:hover {
  border-color: var(--primary);
  background: var(--bg-surface-elevated);
}

.pon-port-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
}

.pon-port-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 1px;
}

/* CLI Terminal Styling */
.terminal-window {
  background: #050811;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.terminal-header {
  background: #0d1222;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.term-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.term-dot.red { background: #ff5f56; }
.term-dot.yellow { background: #ffbd2e; }
.term-dot.green { background: #27c93f; }

.terminal-body {
  padding: 10px;
  height: 280px;
  overflow-y: auto;
  color: #38bdf8;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 11px;
}

.terminal-input-bar {
  display: flex;
  align-items: center;
  background: #090d1a;
  padding: 6px 10px;
  border-top: 1px solid var(--border-subtle);
}

.terminal-prompt {
  color: #10b981;
  font-weight: 700;
  margin-right: 5px;
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  min-height: 28px;
}
