/* ==========================================================================
   DESAIN ANTARMUKA SYSTEM INFORMASI PELABUHAN VTS PANJANG - KEMENHUB
   Theme: Clean White & Crisp Black Line Art (Monochrome Minimalist)
   ========================================================================== */

:root {
  --bg-main: #ffffff;
  --bg-surface: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #000000;
  --text-main: #000000;
  --text-muted: #475569;
  --accent-gold: #000000;
  --status-on: #000000;
  --status-off: #000000;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: #ffffff;
  border-bottom: 2px solid var(--border-color);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.vts-logo-badge {
  width: 42px;
  height: 42px;
  border: 2px solid #000000;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.vts-logo-badge svg {
  width: 24px;
  height: 24px;
  stroke: #000000;
  fill: none;
}

.brand-title h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #000000;
}

.brand-title p {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.realtime-clock {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f1f5f9;
  border: 1px solid #000000;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 700;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #000000;
}

.user-role-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid #000000;
}

.role-viewer {
  background: #ffffff;
  color: #000000;
}

.role-admin {
  background: #000000;
  color: #ffffff;
}

/* Main Container */
.main-container {
  max-width: 1350px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Alert Banner */
.alert-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: #ffffff;
  border: 2px solid #000000;
  border-radius: 6px;
}

.alert-banner-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-icon {
  width: 24px;
  height: 24px;
  stroke: #000000;
}

.alert-banner-text p {
  font-weight: 800;
  font-size: 0.9rem;
  color: #000000;
}

.alert-banner-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* KPI Summary Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: #ffffff;
  border: 1.5px solid #000000;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.kpi-icon-wrapper {
  width: 44px;
  height: 44px;
  border: 1px solid #000000;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-wrapper svg {
  width: 22px;
  height: 22px;
  stroke: #000000;
}

.kpi-info h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-number {
  font-size: 1.6rem;
  font-weight: 800;
  color: #000000;
  line-height: 1.2;
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Section Box Container */
.section-box {
  background: #ffffff;
  border: 1.5px solid #000000;
  border-radius: 6px;
  padding: 1.25rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 800;
  color: #000000;
}

/* Occupancy Heatmap Grid */
.occupancy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.occupancy-card {
  background: #f8fafc;
  border: 1px solid #000000;
  border-radius: 6px;
  padding: 0.85rem;
}

.occupancy-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-weight: 700;
  font-size: 0.85rem;
}

.progress-bar-bg {
  width: 100%;
  height: 12px;
  background: #e2e8f0;
  border: 1px solid #000000;
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #000000;
}

.occupancy-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Radar Map Wrapper */
.radar-map-wrapper {
  position: relative;
  width: 100%;
  height: 380px;
  background: #ffffff;
  border: 1px solid #000000;
  border-radius: 6px;
  overflow: hidden;
}

.radar-grid-bg {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(circle, #cbd5e1 1px, transparent 1px),
    linear-gradient(to right, #f1f5f9 1px, transparent 1px),
    linear-gradient(to bottom, #f1f5f9 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 40px 40px;
}

.radar-center-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.center-label {
  font-size: 0.7rem;
  font-weight: 800;
  background: #ffffff;
  border: 1px solid #000000;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.ship-pin-marker {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid #000000;
  background: #000000;
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 0.2s ease;
}

.ship-pin-marker:hover {
  transform: translate(-50%, -50%) scale(1.6);
}

.pin-panjang   { background: #000000; border-color: #000000; }
.pin-bukitasam { background: #f59e0b; border-color: #d97706; }
.pin-sinarmas  { background: #22c55e; border-color: #16a34a; }
.pin-sebalang  { background: #3b82f6; border-color: #2563eb; }
.pin-ais-off   { background: #ffffff !important; border-width: 2.5px !important; border-color: #ef4444 !important; }

.map-overlay-tag {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: #ffffff;
  border: 1px solid #000000;
  padding: 0.25rem 0.6rem;
  font-weight: 700;
  font-size: 0.75rem;
  border-radius: 4px;
}

/* Table Header Flex Layout */
.table-header-flex {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-left: auto;
}

/* Tabs & Buttons */
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tab-btn {
  padding: 0.5rem 1rem;
  border: 1px solid #000000;
  background: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: 4px;
  cursor: pointer;
}

.tab-btn.active {
  background: #000000;
  color: #ffffff;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  border: 1px solid #000000;
}

.btn-primary   { background: #000000; color: #ffffff; }
.btn-secondary { background: #f1f5f9; color: #000000; }
.btn-outline   { background: #ffffff; color: #000000; }
.btn-dark      { background: #000000; color: #ffffff; }
.btn-danger    { background: #ef4444; color: #ffffff; border-color: #dc2626; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }

/* Filters Toolbar */
.filters-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.2rem;
  border: 1px solid #000000;
  border-radius: 4px;
  font-size: 0.85rem;
}

.search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.filter-group select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #000000;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Action cell buttons */
.action-cell {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.2rem;
  justify-content: center;
  align-items: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.btn-icon-info  { border-color: #0ea5e9; color: #0ea5e9; }
.btn-icon-info:hover  { background: #e0f2fe; }
.btn-icon-edit  { border-color: #f59e0b; color: #d97706; }
.btn-icon-edit:hover  { background: #fef3c7; }
.btn-icon-delete { border-color: #ef4444; color: #ef4444; }
.btn-icon-delete:hover { background: #fee2e2; }

/* Data Table */
.table-responsive {
  overflow-x: auto;
}

.vts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.vts-table th {
  background: #f8fafc;
  border: 1px solid #000000;
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 800;
}

.vts-table td {
  border: 1px solid #e2e8f0;
  padding: 0.55rem 0.75rem;
}

.badge {
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.75rem;
  border: 1px solid #000000;
}

.badge-ais-on { background: #f8fafc; color: #000000; }
.badge-ais-off { background: #000000; color: #ffffff; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop.show { display: flex; }

.modal-card {
  background: #ffffff;
  border: 2px solid #000000;
  border-radius: 6px;
  width: 90%;
  max-width: 500px;
  padding: 1.25rem;
}

.modal-lg { max-width: 700px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #000000;
}

.modal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 700;
}

.form-group input, .form-group select {
  padding: 0.45rem 0.65rem;
  border: 1px solid #000000;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Vessel Spec Modal Card */
.vessel-spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 1rem 0;
  background: #f8fafc;
  padding: 0.85rem;
  border: 1px solid #000000;
  border-radius: 4px;
}

.spec-item span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.spec-coordinate-box {
  background: #ffffff;
  border: 1px solid #000000;
  padding: 0.65rem;
  text-align: center;
  border-radius: 4px;
}

/* Toast Bar */
.toast-bar {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #000000;
  color: #ffffff;
  padding: 0.65rem 1.1rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.8rem;
  display: none;
  z-index: 1100;
}

/* Map Section Header & Legend */
.section-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title-group .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #000;
  flex-shrink: 0;
}

.dot-panjang   { background: #000000; }
.dot-bukitasam { background: #f59e0b; border-color: #d97706; }
.dot-sinarmas  { background: #22c55e; border-color: #16a34a; }
.dot-sebalang  { background: #3b82f6; border-color: #2563eb; }
.dot-ais-off   { background: #ffffff; border: 2.5px solid #000; }

/* Missing utility classes */
.coordinate-text { font-family: monospace; font-size: 0.8rem; }
.badge-terminal-panjang { background: #f1f5f9; color: #000; border: 1px solid #000; }
.btn-outline-gold { background: #fff; color: #000; border: 1px solid #000; }

/* ======================================================
   MOBILE RESPONSIVE (max-width: 768px)
   ====================================================== */
@media (max-width: 768px) {
  /* Header */
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .realtime-clock, .user-role-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }

  .brand-title h1 { font-size: 1rem; }
  .brand-title p  { font-size: 0.72rem; }

  /* Main container */
  .main-container { padding: 0 0.75rem; margin: 1rem auto; gap: 1rem; }

  /* Alert banner */
  .alert-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  /* KPI grid: 2 kolom di tablet, 1 di mobile kecil */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .kpi-card { padding: 0.75rem; gap: 0.65rem; }
  .kpi-number { font-size: 1.35rem; }
  .kpi-info h3 { font-size: 0.7rem; }

  /* Occupancy grid: 1 kolom */
  .occupancy-grid { grid-template-columns: 1fr; }

  /* Radar map: tinggi lebih kecil */
  .radar-map-wrapper { height: 260px; }

  /* Section header: stack */
  .section-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .section-header h2 { font-size: 0.85rem; }
  .map-legend { gap: 0.3rem 0.6rem; }

  /* Table header: stack tab di atas, buttons di bawah */
  .table-header-flex {
    flex-direction: column;
    gap: 0.5rem;
  }

  .nav-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.25rem; }

  .tab-btn { font-size: 0.72rem; padding: 0.4rem 0.65rem; white-space: nowrap; }

  .action-buttons {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  /* Filters: stack */
  .filters-toolbar {
    flex-direction: column;
    gap: 0.5rem;
  }

  .filter-group { width: 100%; }
  .filter-group select { flex: 1; min-width: 0; font-size: 0.8rem; }

  /* Table: biarkan scroll horizontal */
  .vts-table { font-size: 0.75rem; }
  .vts-table th, .vts-table td { padding: 0.4rem 0.5rem; }

  /* Modal: full width */
  .modal-card { width: 96%; padding: 1rem; }
  .modal-grid-2 { grid-template-columns: 1fr; }
  .vessel-spec-grid { grid-template-columns: 1fr; }

  /* Toast */
  .toast-bar { right: 10px; left: 10px; text-align: center; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .brand-title h1 { font-size: 0.9rem; }
  .vts-logo-badge { width: 34px; height: 34px; }
}

/* Print CSS */
.print-header, .print-footer { display: none; }
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: #fff !important; color: #000 !important; font-size: 10pt; margin: 0; padding: 0; }

  /* Sembunyikan semua elemen UI */
  .app-header, .alert-banner, .header-actions, .action-buttons,
  .filters-toolbar, .nav-tabs, .kpi-grid, .section-box.map-section,
  .section-box.occupancy-heatmap, .modal-backdrop,
  #toast-notification, .action-cell, .no-print { display: none !important; }

  /* Tampilkan header resmi */
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #000;
    padding-bottom: 0.75rem;
  }
  .print-header h3 { font-size: 13pt; margin: 0.1rem 0; text-transform: uppercase; }
  .print-header h4 { font-size: 11pt; margin: 0.3rem 0; }
  .print-header p  { font-size: 10pt; margin: 0.1rem 0; }

  /* Tabel print */
  .section-box.table-section {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .table-responsive { overflow: visible !important; }

  .vts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 8.5pt;
    page-break-inside: auto;
  }

  .vts-table th {
    background: #e0e0e0 !important;
    color: #000 !important;
    border: 1px solid #000 !important;
    padding: 0.3rem 0.4rem !important;
    font-size: 8pt !important;
    text-align: center;
  }

  .vts-table td {
    border: 1px solid #666 !important;
    padding: 0.25rem 0.4rem !important;
    font-size: 8pt !important;
  }

  .vts-table tr { page-break-inside: avoid; }
  .vts-table tr:nth-child(even) td { background: #f5f5f5 !important; }

  .badge {
    border: 1px solid #000 !important;
    background: transparent !important;
    color: #000 !important;
    font-size: 7pt !important;
    padding: 1px 4px !important;
  }

  .badge-ais-off {
    border: 1.5px solid #000 !important;
    font-weight: 900 !important;
  }

  /* Occupancy section — tampilkan di print */
  .section-box:not(.map-section):not(.table-section) {
    display: block !important;
    page-break-inside: avoid;
  }

  /* Footer tanda tangan */
  .print-footer {
    display: block !important;
    margin-top: 1.5rem;
    border-top: 1px solid #000;
    padding-top: 0.75rem;
    page-break-inside: avoid;
  }

  .print-summary-box {
    background: #f0f0f0 !important;
    border: 1px solid #000 !important;
    padding: 0.5rem !important;
    margin-bottom: 1rem;
    font-size: 9pt;
  }

  .print-signatures {
    display: flex !important;
    justify-content: space-around;
  }

  .sig-box {
    text-align: center;
    font-size: 9pt;
    min-width: 200px;
  }

  @page {
    size: A4 landscape;
    margin: 1.5cm 1cm;
  }
}
