/* Port Bonython Tracker Styles */

:root {
  --primary: #1e3a5f;
  --primary-light: #2d5a8a;
  --accent: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  background: var(--primary);
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Port navigation tabs */
.port-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.header-status {
  margin-left: auto;
}

.port-tab {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.port-tab:hover {
  background: var(--primary-light);
  color: white;
}

.port-tab.active {
  background: white;
  color: var(--primary);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-500);
}

.status-dot.connected {
  background: var(--success);
}

.status-dot.error {
  background: var(--danger);
}

/* Refresh timer circle */
.refresh-timer {
  width: 20px;
  height: 20px;
  cursor: help;
}

.refresh-timer svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.refresh-timer .timer-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 2;
}

.refresh-timer .timer-progress {
  fill: none;
  stroke: var(--success);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 50.27;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s linear;
}

/* Main content */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Map */
#map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

/* Sidebar */
.sidebar {
  width: 380px;
  max-height: 100vh;
  background: white;
  border-left: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
}

.panel {
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 1rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.badge {
  background: var(--primary);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Vessel list */
.vessel-list,
.port-calls-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.vessel-item,
.port-call-item {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 0.5rem;
}

.vessel-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.vessel-item:hover,
.port-call-item:hover {
  background: var(--gray-100);
}

.vessel-item.selected {
  background: var(--gray-200);
}

.vessel-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}

.vessel-details {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--gray-500);
  flex-shrink: 0;
}

.vessel-flag {
  font-size: 1rem;
}

.flag-code {
  font-size: 0.75rem;
  color: var(--gray-400);
}

.vessel-type {
  white-space: nowrap;
}

.vessel-meta {
  font-size: 0.875rem;
  color: var(--gray-500);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.cargo-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.cargo-badge.lpg {
  background: #dbeafe;
  color: #1e40af;
}

.cargo-badge.crude {
  background: #fef3c7;
  color: #92400e;
}

.cargo-badge.products {
  background: #d1fae5;
  color: #065f46;
}

.cargo-badge.unknown {
  background: var(--gray-200);
  color: var(--gray-700);
}

/* Filter bar */
.filter-bar {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  gap: 0.5rem;
  background: var(--gray-50);
}

.filter-bar select {
  flex: 1;
  padding: 0.375rem 0.5rem;
  font-size: 0.8rem;
}

/* Color-coded vessel items */
.vessel-item {
  border-left: 4px solid var(--gray-300);
}

.vessel-item.cargo-lpg {
  border-left-color: #3b82f6;
  background: linear-gradient(to right, rgba(59, 130, 246, 0.08), transparent);
}

.vessel-item.cargo-crude {
  border-left-color: #f59e0b;
  background: linear-gradient(to right, rgba(245, 158, 11, 0.08), transparent);
}

.vessel-item.cargo-products {
  border-left-color: #10b981;
  background: linear-gradient(to right, rgba(16, 185, 129, 0.08), transparent);
}

.vessel-item.cargo-unknown {
  border-left-color: #8b5cf6;
  background: linear-gradient(to right, rgba(139, 92, 246, 0.08), transparent);
}

/* Flag display */
.vessel-flag {
  font-size: 1rem;
  margin-right: 0.25rem;
}

.flag-code {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
}

/* Destination display */
.vessel-dest {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 500;
  background: rgba(30, 58, 95, 0.1);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  margin-right: 0.5rem;
}

.vessel-dest.arrived {
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

/* Support vessels (tugs, pilots) */
.vessel-item.support-vessel {
  border-left-color: #6366f1;
  background: linear-gradient(to right, rgba(99, 102, 241, 0.05), transparent);
  opacity: 0.8;
}

.vessel-item.support-vessel .vessel-name {
  font-weight: 500;
}

/* Leaflet tooltip styling */
.vessel-tooltip {
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border: none;
}

.vessel-tooltip::before {
  border-top-color: white;
}

/* Navigation tabs */
.nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.nav-tab {
  flex: 1;
  padding: 0.75rem;
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.15s;
}

.nav-tab:hover {
  background: var(--gray-50);
}

.nav-tab.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 0.75rem;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-500);
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
}

.modal-close:hover {
  background: var(--gray-100);
}

#vessel-detail {
  padding: 1.5rem;
}

.detail-header {
  margin-bottom: 1.5rem;
}

.detail-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.detail-subtitle {
  color: var(--gray-500);
}

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.detail-item {
  font-size: 0.875rem;
}

.detail-item label {
  color: var(--gray-500);
  display: block;
  margin-bottom: 0.125rem;
}

.detail-item span {
  font-weight: 500;
}

.cargo-box {
  background: var(--gray-50);
  border-radius: 0.5rem;
  padding: 1rem;
}

.cargo-box .category {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.cargo-box .confidence {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
}

.cargo-box .reasoning {
  font-size: 0.875rem;
  line-height: 1.6;
}

.history-list {
  font-size: 0.875rem;
}

.history-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
}

.history-item:last-child {
  border-bottom: none;
}

/* Loading & empty states */
.loading,
.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--gray-500);
}

/* Port call item */
.port-call-item .date {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 0.25rem;
}

.port-call-item .times {
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* Select */
select {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background: white;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }

  #map-container {
    height: 50vh;
  }

  .sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--gray-200);
  }
}
