/* Ninja Polar — Styles */

/* ── Page Layout ─────────────────────────────────────────── */
.pl-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.pl-back {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: #666;
  text-decoration: none;
}
.pl-back:hover { color: #1a2a44; }

.pl-header {
  margin-bottom: 1.5rem;
}
.pl-header__title {
  font-size: 1.6rem;
  color: #1a2a44;
  margin: 0;
}
.pl-header__sub {
  color: #666;
  font-size: 0.9rem;
  margin: 2px 0 0;
}

/* ── Cards ────────────────────────────────────────────────── */
.pl-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.pl-card__title {
  font-size: 14px;
  font-weight: 700;
  color: #1a2a44;
  margin: 0 0 12px;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.pl-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0;
}
.pl-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: #999;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.pl-tab:hover { color: #1a2a44; }
.pl-tab.active {
  color: #1a2a44;
  border-bottom-color: #1a2a44;
}
.pl-tab-panel { display: none; }
.pl-tab-panel.active { display: block; }

/* ── Form Elements ────────────────────────────────────────── */
.pl-input, .pl-select, .pl-textarea {
  padding: 8px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 14px;
  color: #333;
  background: #fff;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.pl-input:focus, .pl-select:focus, .pl-textarea:focus {
  outline: none;
  border-color: #1a2a44;
  box-shadow: 0 0 0 3px rgba(26, 42, 68, 0.1);
}
.pl-input--sm { width: 70px; padding: 6px 8px; font-size: 13px; }
.pl-textarea { width: 100%; resize: vertical; font-family: monospace; font-size: 13px; }
.pl-hint { font-size: 12px; color: #999; margin: 0 0 10px; }
.pl-status { font-size: 13px; color: #666; margin-top: 10px; min-height: 18px; }
.pl-status.error { color: #dc2626; }

.pl-field { display: flex; flex-direction: column; gap: 4px; }
.pl-field label { font-size: 12px; font-weight: 600; color: #666; }

/* ── Library Select ──────────────────────────────────────── */
.pl-library-search select {
  font-size: 13px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  cursor: pointer;
}
.pl-library-search select option {
  padding: 4px 8px;
}
.pl-library-search select option:checked {
  background: #1a2a44;
  color: #fff;
}

/* ── Buttons ──────────────────────────────────────────────── */
.pl-btn {
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: #fff;
  color: #444;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.pl-btn:hover { border-color: #1a2a44; color: #1a2a44; }
.pl-btn--primary {
  background: #1a2a44;
  color: #fff;
  border-color: #1a2a44;
}
.pl-btn--primary:hover { background: #253a5a; color: #fff; }
.pl-btn--danger:hover { border-color: #dc2626; color: #dc2626; }

/* ── Import Rows ──────────────────────────────────────────── */
.pl-import-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.pl-import-row .pl-input { flex: 1; min-width: 200px; }

/* ── Drop Zone ────────────────────────────────────────────── */
.pl-dropzone {
  border: 2px dashed #d0d5dd;
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pl-dropzone:hover, .pl-dropzone.dragover {
  border-color: #1a2a44;
  background: rgba(26, 42, 68, 0.03);
}

/* ── Estimate Grid ────────────────────────────────────────── */
.pl-estimate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.pl-estimate-grid .pl-input,
.pl-estimate-grid .pl-select {
  width: 100%;
}

/* ── Manual Entry Config ──────────────────────────────────── */
.pl-manual-config {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.pl-manual-config label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Boat Info ────────────────────────────────────────────── */
.pl-boat-info__row {
  display: flex;
  gap: 14px;
}
.pl-boat-info__row .pl-field { flex: 1; }
.pl-boat-info__row .pl-input { width: 100%; }

/* ── Modifiers ────────────────────────────────────────────── */
.pl-mod-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.pl-mod {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pl-mod > label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
}
.pl-mod__control {
  display: flex;
  gap: 6px;
  align-items: center;
}
.pl-mod__control input[type="range"] {
  width: 120px;
}

/* ── Chart ────────────────────────────────────────────────── */
.pl-chart-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
}
.pl-chart-wrap {
  display: flex;
  position: relative;
}
.pl-chart-label {
  position: absolute;
  top: 10px;
  left: 14px;
  color: #1a2a44;
  font-size: 13px;
  font-weight: 600;
  z-index: 2;
}
.pl-chart {
  flex: 1;
  min-width: 0;
  display: block;
}
.pl-chart-panel {
  width: 170px;
  flex-shrink: 0;
  background: #f9fafb;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}
.pl-panel-data {
  flex: 1;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.pl-panel-hint {
  color: #999;
  font-size: 12px;
  text-align: center;
  line-height: 1.5;
}
.pl-panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid #eee;
}
.pl-panel-row:last-child { border-bottom: none; }
.pl-panel-row--header {
  border-bottom: 2px solid #ddd;
  padding-bottom: 6px;
  margin-bottom: 2px;
}
.pl-panel-row--header .pl-panel-val {
  font-size: 16px;
}
.pl-panel-label {
  color: #666;
  font-size: 12px;
  font-weight: 600;
}
.pl-panel-val {
  color: #1a2a44;
  font-size: 14px;
  font-weight: 700;
  font-family: monospace;
}
.pl-panel-tws {
  border-top: 1px solid #e5e7eb;
  padding: 14px;
}
.pl-panel-tws__label {
  color: #666;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
}
.pl-panel-tws__controls {
  margin-bottom: 8px;
}
.pl-panel-tws__angles {
  color: #888;
  font-size: 11px;
  text-align: center;
}

.pl-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 12px;
  justify-content: center;
}
.pl-legend__item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #666;
}
.pl-legend__swatch {
  width: 20px;
  height: 3px;
  border-radius: 2px;
}
.pl-legend__marker {
  font-size: 11px;
  color: #999;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Data Table ───────────────────────────────────────────── */
.pl-table-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.pl-table-wrap {
  overflow-x: auto;
}
.pl-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
.pl-table th, .pl-table td {
  border: 1px solid #e5e7eb;
  padding: 6px 10px;
  text-align: right;
  white-space: nowrap;
}
.pl-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #1a2a44;
  position: sticky;
  top: 0;
}
.pl-table td:first-child, .pl-table th:first-child {
  text-align: left;
  font-weight: 600;
  color: #444;
  background: #f9fafb;
}
.pl-table tr.pl-table__vmg {
  background: #f0f7ff;
  font-style: italic;
}
.pl-table td input {
  width: 60px;
  padding: 3px 6px;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
}
.pl-table td input:focus {
  outline: none;
  border-color: #1a2a44;
}

/* ── Print Layout ─────────────────────────────────────────── */
@media print {
  @page { size: letter landscape; margin: 0.3in 0.2in 0.3in 0.3in; }
  body > *:not(.pl-print) { display: none !important; }
  .pl-print {
    display: flex !important;
    gap: 12px;
    align-items: stretch;
    height: 100vh;
    width: 98%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* ── Left: Chart + Vertical Legend ── */
  .pl-print__chart {
    flex: 0 0 40%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    min-width: 0;
    padding-right: 12px;
    box-sizing: border-box;
  }
  .pl-print__svg-wrap {
    flex: 1;
    min-width: 0;
  }
  .pl-print__svg-wrap svg {
    width: 100%;
    height: auto;
  }
  .pl-print__legend {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 9px;
    color: #555;
    flex-shrink: 0;
    padding: 4px 0;
  }
  .pl-print__leg-item {
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
  }

  /* ── Right: Title + Table + Date ── */
  .pl-print__data {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: visible;
  }
  .pl-print__title {
    font-size: 15px;
    font-weight: 700;
    color: #1a2a44;
    margin: 0 0 4px;
    border-bottom: 2px solid #1a2a44;
    padding-bottom: 4px;
  }
  .pl-print__sub {
    font-size: 10px;
    color: #666;
    margin: 0 0 8px;
  }
  .pl-print__data table {
    border-collapse: collapse;
    width: 100%;
    flex: 1;
    table-layout: fixed;
  }
  .pl-print__data th, .pl-print__data td {
    border: 1px solid #d0d0d0;
    padding: 4px 6px;
    text-align: center;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .pl-print__data th {
    background: #1a2a44;
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    padding: 7px 8px;
  }
  /* Alternating column shading — every other TWS column */
  .pl-print__col-shade {
    background: #e8eaef !important;
  }
  th.pl-print__col-shade {
    background: #2a3a54 !important;
  }
  .pl-print__twa-col {
    text-align: left !important;
    font-weight: 700;
    width: 56px;
    padding-left: 6px;
    padding-right: 6px;
  }
  th.pl-print__twa-col {
    background: #1a2a44 !important;
    color: #fff !important;
  }
  td.pl-print__twa-col {
    color: #1a2a44;
    background: #e8eaee !important;
  }
  .pl-print__vmg-row td {
    font-style: italic;
    font-weight: 600;
    color: #444;
    border-top: 2px solid #1a2a44;
  }
  .pl-print__vmg-row .pl-print__col-shade {
    background: #e4e8f0;
  }
  .pl-print__vmg-bottom td {
    border-bottom: 3px solid #1a2a44 !important;
  }
  .pl-print__date {
    text-align: right;
    font-size: 8px;
    color: #aaa;
    margin-top: 6px;
  }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
  .pl-page { padding: 1.25rem 1rem 3rem; }
  .pl-tabs { overflow-x: auto; }
  .pl-boat-info__row { flex-direction: column; }
  .pl-mod-row { flex-direction: column; }
  .pl-import-row { flex-direction: column; }
  .pl-import-row .pl-input { min-width: 0; }
  .pl-table-toolbar { flex-wrap: wrap; }
  .pl-chart-wrap { flex-direction: column; }
  .pl-chart-panel { width: 100%; border-left: none; border-top: 1px solid #e5e7eb; flex-direction: row; }
  .pl-panel-data { padding: 10px 14px; }
  .pl-panel-tws { border-top: none; border-left: 1px solid #e5e7eb; }
}
