/* iFly — ShadowWing Linear Dark Design System */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure [hidden] always wins over any display rule in this stylesheet */
[hidden] { display: none !important; }

:root {
  --bg:           #0d1117;
  --bg-panel:     #161b22;
  --bg-surface:   #1c2128;
  --bg-hover:     #22272e;
  --border:       #30363d;
  --border-light: #21262d;

  --teal:         #00d4aa;
  --teal-dim:     #00a882;
  --amber:        #f0a020;
  --red:          #ff4d4d;
  --red-dim:      #cc3333;
  --green:        #3fb950;
  --yellow:       #f0a500;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --font-head: 'Barlow Condensed', sans-serif;
  --font-mono: 'Geist Mono', monospace;

  --nav-w:    48px;
  --char-w:   175px;
  --radius:   4px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dim); }

/* ── App Shell — 3-column layout ─────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--nav-w) var(--char-w) 1fr;
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
}

/* ── Nav Icons (col 1) ────────────────────────────────────── */
.nav-icons {
  grid-column: 1;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 0;
  overflow: hidden;
}

.nav-logo {
  width: 100%;
  text-align: center;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-i   { color: var(--teal); }
.logo-fly { color: var(--text-primary); }

.nav-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  width: 100%;
}

.nav-bottom {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 8px;
}

.nav-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  width: 100%;
  color: var(--text-secondary);
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
}

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

.nav-icon:hover,
.nav-icon.active {
  color: var(--teal);
  background: rgba(0, 212, 170, 0.08);
}

.nav-logout:hover { color: var(--red); background: rgba(255, 77, 77, 0.08); }

/* ── Character Panel (col 2) ──────────────────────────────── */
.char-panel {
  grid-column: 2;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.char-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-label {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.char-add-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--teal);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.char-add-btn:hover { background: var(--bg-hover); }

.char-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.char-item {
  position: relative;
  display: flex;
  align-items: center;
}

.char-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--text-primary);
  transition: background 0.1s;
  min-width: 0;
}

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

.char-item.active .char-link {
  background: rgba(0, 212, 170, 0.08);
  border-left: 2px solid var(--teal);
}

.char-portrait {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  flex-shrink: 0;
  background: var(--bg-surface);
}

.char-name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.char-remove {
  padding: 4px 6px;
  color: var(--text-muted);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.char-item:hover .char-remove { opacity: 1; }
.char-remove:hover { color: var(--red); }

/* ── Detail Panel (col 3) ─────────────────────────────────── */
.detail-panel {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Character Header ─────────────────────────────────────── */
.char-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
}

.char-header-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.char-header-portrait {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.char-header-name {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.char-header-wallet {
  display: flex;
  gap: 6px;
  font-size: 12px;
}
.char-header-wallet .label { color: var(--text-muted); }
.char-header-wallet .value { color: var(--amber); font-weight: 500; }

.char-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.skill-count-badge {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Detail Body ──────────────────────────────────────────── */
.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Skills Overview ──────────────────────────────────────── */
#skills-overview {
  flex-shrink: 0;
}

.overview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 90px;
}

.stat-value {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.stat-level-5 .stat-value { color: var(--teal); }
.stat-level-4 .stat-value { color: var(--green); }
.stat-level-3 .stat-value { color: var(--amber); }
.stat-level-2 .stat-value { color: var(--text-secondary); }
.stat-level-1 .stat-value { color: var(--text-muted); }

.overview-cta {
  padding: 8px 0 4px;
}

.overview-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Ship Selector ────────────────────────────────────────── */
.ship-selector { flex-shrink: 0; }

.ship-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.ship-search-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.ship-search-input:focus { border-color: var(--teal); }
.ship-search-input::placeholder { color: var(--text-muted); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
}

.dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item img { width: 24px; height: 24px; border-radius: 2px; }

.selected-ship-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
}

.ship-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--bg-panel);
}

.ship-meta { display: flex; flex-direction: column; gap: 2px; }
.ship-meta-name { font-family: var(--font-head); font-size: 16px; font-weight: 600; }
.ship-meta-status { font-size: 11px; }
.ship-meta-status.can-fly  { color: var(--green); }
.ship-meta-status.cant-fly { color: var(--red); }
.ship-meta-status.partial  { color: var(--amber); }

/* ── Skill Comparison ─────────────────────────────────────── */
.skill-comparison { flex: 1; }

.skill-comparison-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-icon { font-size: 36px; }

.skill-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.skill-table th {
  text-align: left;
  padding: 6px 10px;
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.skill-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.skill-row.ok     .skill-name { color: var(--green); }
.skill-row.partial .skill-name { color: var(--amber); }
.skill-row.missing .skill-name { color: var(--red); }

.pips {
  display: flex;
  gap: 3px;
  align-items: center;
}

.pip {
  width: 10px;
  height: 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
}
.pip.filled    { background: var(--teal); border-color: var(--teal); }
.pip.filled-ok { background: var(--green); border-color: var(--green); }
.pip.filled-miss { background: var(--red); border-color: var(--red); }

.training-time-cell { color: var(--amber); font-size: 11px; }
.ok-cell { color: var(--green); font-size: 11px; }

/* Mastery pips (I–V) */
.mastery-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  padding: 4px 0;
}
.mastery-pip {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}
.mastery-pip.earned { background: var(--yellow); border-color: var(--yellow); }

/* ── Action Bar ───────────────────────────────────────────── */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.action-bar-left { display: flex; align-items: center; gap: 12px; }
.action-bar-right { display: flex; align-items: center; gap: 10px; }

.action-ship-name {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
}

.action-mastery { display: flex; gap: 3px; align-items: center; }

.action-training-time {
  font-size: 11px;
  color: var(--amber);
}

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

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(600px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius);
  line-height: 1;
}
.modal-close:hover { color: var(--red); background: rgba(255, 77, 77, 0.1); }

.modal-body {
  overflow-y: auto;
  padding: 16px 18px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-cta {
  background: var(--teal);
  color: #0d1117;
}
.btn-cta:hover { background: var(--teal-dim); color: #0d1117; }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 12px 28px; font-size: 14px; }

.btn-icon { width: 16px; height: 16px; }

/* ── Alert ────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  border: 1px solid;
}
.alert-error { background: rgba(255, 77, 77, 0.1); border-color: var(--red); color: var(--red); }

/* ── Landing Page ─────────────────────────────────────────── */
.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 520px;
  width: 100%;
  text-align: center;
}

.landing-logo {
  font-family: var(--font-head);
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
}

.landing-tagline {
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.landing-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.landing-chars {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.char-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.landing-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
}

.feature-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }

.feature-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.feature-text strong { font-size: 13px; color: var(--text-primary); font-family: var(--font-head); font-weight: 600; }
.feature-text span   { font-size: 11px; color: var(--text-secondary); }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-panel); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444c56; }

/* ── Loading state ────────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 4px;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn.loading { opacity: 0.7; pointer-events: none; }
