/* style.css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: #f6f8fa;
  color: #111;
  overflow-x: hidden;
}

header {
  background: linear-gradient(135deg, #0b5cff 0%, #0845cc 100%);
  color: white;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.status-bar {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e74c3c;
}

.status-dot.connected {
  background: #2ecc71;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Alert Banner */
.alert-banner {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideDown 0.3s ease;
}

.alert-banner.critical {
  background: #f8d7da;
  border-left-color: #dc3545;
}

@keyframes slideDown {
  from { max-height: 0; opacity: 0; }
  to { max-height: 100px; opacity: 1; }
}

/* Tab Navigation */
.tab-nav {
  background: white;
  border-bottom: 2px solid #e9ecef;
  display: flex;
  gap: 0;
  overflow-x: auto;
  position: sticky;
  top: 56px;
  z-index: 999;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #0b5cff;
  background: #f8f9fa;
}

.tab-btn.active {
  color: #0b5cff;
  border-bottom-color: #0b5cff;
}

/* Tab Content */
.tab-content {
  position: relative;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Map Styles */
#map {
  width: 100%;
  height: calc(100vh - 130px);
  background: #b4d4e1;
}

.leaflet-container {
  font-family: inherit;
}

.map-overlay {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  min-width: 250px;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e9ecef;
  font-weight: 600;
  color: #333;
}

.overlay-header button {
  background: #0b5cff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s;
}

.overlay-header button:hover {
  background: #0845cc;
}

.overlay-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.overlay-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.overlay-label {
  color: #666;
  font-weight: 500;
}

.overlay-value {
  font-weight: 600;
  font-family: monospace;
  color: #111;
}

.overlay-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e9ecef;
  font-size: 12px;
}

.overlay-footer label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

/* Card Styles */
.card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f0f0f0;
}

.card-icon {
  font-size: 22px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

/* Metrics */
.metric {
  margin: 12px 0;
}

.metric-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 28px;
  font-weight: 600;
  font-family: monospace;
  color: #111;
}

.metric-unit {
  font-size: 16px;
  color: #666;
  margin-left: 4px;
}

/* Gauges */
.gauge {
  margin: 16px 0;
}

.gauge-label {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.gauge-bar {
  height: 24px;
  background: #e9ecef;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.gauge-fill {
  height: 100%;
  background: linear-gradient(90deg, #2ecc71 0%, #27ae60 100%);
  border-radius: 12px;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: white;
  font-size: 12px;
  font-weight: 600;
}

.gauge-fill.warning {
  background: linear-gradient(90deg, #f39c12 0%, #e67e22 100%);
}

.gauge-fill.critical {
  background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%);
}

/* Compass */
.compass {
  width: 180px;
  height: 180px;
  margin: 16px auto;
  position: relative;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 60%, #f0f0f0 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.compass-needle {
  position: absolute;
  width: 4px;
  height: 70px;
  background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
  left: 50%;
  top: 20px;
  transform-origin: 50% 70px;
  transform: translateX(-50%) rotate(0deg);
  border-radius: 2px;
  transition: transform 0.5s ease;
}

.compass-center {
  position: absolute;
  width: 20px;
  height: 20px;
  background: #333;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid white;
  z-index: 10;
}

.compass-label {
  position: absolute;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.compass-label.n { top: 10px; left: 50%; transform: translateX(-50%); }
.compass-label.e { right: 10px; top: 50%; transform: translateY(-50%); }
.compass-label.s { bottom: 10px; left: 50%; transform: translateX(-50%); }
.compass-label.w { left: 10px; top: 50%; transform: translateY(-50%); }

/* Data Grid */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.data-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.data-label {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-value {
  font-size: 18px;
  font-weight: 600;
  font-family: monospace;
  color: #111;
}

/* Attitude Indicators */
.attitude-indicators {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.attitude-item {
  text-align: center;
}

.attitude-label {
  font-size: 11px;
  color: #666;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.attitude-value {
  font-size: 24px;
  font-weight: 600;
  font-family: monospace;
  color: #0b5cff;
}

/* Battery Grid */
.battery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.battery-item {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 6px;
  border-left: 3px solid #2ecc71;
  transition: all 0.3s;
}

.battery-item.inactive {
  opacity: 0.4;
  border-left-color: #ccc;
}

.battery-item.warning {
  border-left-color: #f39c12;
}

.battery-item.critical {
  border-left-color: #e74c3c;
}

.battery-label {
  font-size: 11px;
  color: #666;
  margin-bottom: 4px;
}

.battery-voltage {
  font-size: 20px;
  font-weight: 600;
  font-family: monospace;
  color: #111;
}

/* Device List */
.device-list {
  margin-top: 12px;
}

.device-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 8px;
  transition: background 0.2s;
}

.device-item:hover {
  background: #e9ecef;
}

.device-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-name {
  font-weight: 600;
  font-size: 13px;
}

.device-type {
  font-size: 11px;
  color: #666;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: #d4edda;
  color: #155724;
}

.status-badge.warning {
  background: #fff3cd;
  color: #856404;
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  padding: 12px;
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
  font-weight: 600;
  color: #333;
}

.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  font-family: monospace;
}

.data-table tbody td:first-child {
  font-weight: 600;
  color: #0b5cff;
}

.decoded {
  font-family: inherit;
}

.details {
  color: #444;
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.4;
}

/* Control Buttons */
.control-btn {
  background: rgba(11, 92, 255, 0.1);
  border: 1px solid rgba(11, 92, 255, 0.3);
  color: #0b5cff;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}

.control-btn:hover {
  background: rgba(11, 92, 255, 0.2);
}

.control-btn.active {
  background: #0b5cff;
  color: white;
}

/* Footer */
footer {
  text-align: center;
  padding: 20px;
  color: #666;
  font-size: 12px;
  margin-top: 40px;
  border-top: 1px solid #e9ecef;
}

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .status-bar {
    width: 100%;
    justify-content: space-between;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .map-overlay {
    right: 10px;
    top: 10px;
    min-width: 200px;
  }
  
  .tab-nav {
    top: 90px;
  }
  
  #map {
    height: calc(100vh - 160px);
  }
}

/* Boat Icon Styles */
.boat-marker {
  width: 40px;
  height: 40px;
}

.boat-icon {
  position: relative;
  width: 40px;
  height: 40px;
  transform-origin: center;
}

/* Create boat hull shape */
.boat-icon::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 32px;
  background: #e74c3c;
  border-radius: 50% 50% 0 0;
  top: 0;
  left: 12px;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* Boat stern (back) */
.boat-icon::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 8px;
  background: #c0392b;
  border-radius: 0 0 50% 50%;
  bottom: 0;
  left: 10px;
  border: 3px solid white;
  border-top: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* Heading indicator line */
.boat-heading-line {
  position: absolute;
  width: 2px;
  height: 20px;
  background: white;
  top: -20px;
  left: 19px;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}