/* ==========================================================================
   Coriolis CMDR - CSS Theme
   Matching coriolis.io visual style (derived from coriolis LESS sources)
   ========================================================================== */

/* -- Fonts ----------------------------------------------------------------- */

@font-face {
  font-family: 'Eurostile';
  src: url('../fonts/eurostile.eot');
  src: url('../fonts/eurostile.eot?#iefix') format('embedded-opentype'),
       url('../fonts/eurostile.woff2') format('woff2'),
       url('../fonts/eurostile.woff') format('woff'),
       url('../fonts/eurostile.ttf') format('truetype'),
       url('../fonts/eurostile.svg#euro_capsregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

/* -- CSS Variables (from colors.less) -------------------------------------- */

:root {
  /* Foreground */
  --fg:                 #CCC;
  --muted:              #999;
  --primary:            #FF8C0D;       /* Light Orange */
  --secondary:          #1FB0FF;       /* Light Blue   */
  --warning:            #FF3B00;       /* Dark Orange  */
  --disabled:           #555;
  --success:            #71a052;

  /* Derived foreground */
  --primary-disabled:   #b35600;
  --secondary-disabled: #006eb3;
  --warning-disabled:   #b32900;

  /* Backgrounds */
  --bg:                 rgba(30,30,30,1);
  --bg-black:           #000;
  --primary-bg:         rgba(37,22,5,0.85);
  --alt-primary-bg:     rgba(48,30,8,0.85);
  --secondary-bg:       rgba(0,30,56,0.9);
  --warning-bg:         rgba(56,10,0,0.9);

  /* Highlighted */
  --alt-primary-bg-hl:  rgba(61,43,21,0.85);
  --fg-highlighted:     #e0e0e0;
  --primary-darker:     #663800;

  /* Fonts */
  --f-standard:         'Eurostile', Helvetica, sans-serif;
  --f-title:            'Eurostile', Arial, sans-serif;
}

/* -- Reset & Base ---------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  text-rendering: optimizeLegibility;
}

body {
  color: var(--fg);
  background-color: var(--bg-black);
  font-family: var(--f-standard);
  letter-spacing: 0.05em;
  font-size: 14px;
  line-height: 1.4;
  overflow-x: hidden;
}

/* -- Typography ------------------------------------------------------------ */

h1 {
  font-family: var(--f-title);
  color: var(--primary);
  font-size: 1.6em;
  letter-spacing: 0.1em;
  margin: 0;
}

h2 {
  text-transform: uppercase;
  font-family: var(--f-standard);
  font-size: 1.2em;
  font-weight: normal;
  color: var(--primary);
}

h3 {
  text-transform: uppercase;
  font-family: var(--f-standard);
  font-weight: normal;
  font-size: 1em;
  margin: 0.2em 0;
  color: var(--primary);
}

p {
  text-align: justify;
  line-height: 1.6;
}

a, a:visited {
  color: var(--fg);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary);
}

u {
  font-size: 0.8em;
  text-decoration: none;
  text-transform: none;
}

/* -- Layout ---------------------------------------------------------------- */

#page-wrapper {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* -- Header ---------------------------------------------------------------- */

header {
  background-color: var(--bg);
  margin: 0;
  padding: 0 1em;
  height: 3em;
  line-height: 3em;
  font-family: var(--f-title);
  vertical-align: middle;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  border-bottom: 1px solid var(--primary-darker);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25em;
}

.coriolis-logo {
  display: flex;
  align-items: center;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.coriolis-logo:hover {
  opacity: 1;
}

.coriolis-logo svg {
  display: block;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25em;
}

.nav-btn {
  color: var(--muted);
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.08em;
  font-size: 0.85em;
  font-family: var(--f-title);
  padding: 0 0.75em;
  height: 3em;
  line-height: 3em;
  display: inline-block;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-btn:hover {
  color: var(--fg-highlighted);
}

.nav-btn.active {
  color: var(--warning);
  border-bottom-color: var(--warning);
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 1.25em;
  font-size: 0.85em;
}

.user-nav a {
  color: var(--secondary);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color 0.15s ease;
}

.user-nav a:hover {
  color: var(--fg-highlighted);
}

.user-nav span {
  color: var(--muted);
}

/* -- Main Content ---------------------------------------------------------- */

main {
  flex: 1;
  padding: 1.5em;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.page {
  margin: 0;
  padding: 0.5em;
  width: 100%;
  min-height: 100%;
  clear: both;
  text-align: center;
}

/* -- Footer ---------------------------------------------------------------- */

footer {
  clear: both;
  font-size: 0.6em;
  color: var(--muted);
  padding: 1em;
  overflow: hidden;
  text-align: center;
  border-top: 1px solid var(--primary-darker);
}

/* -- Buttons --------------------------------------------------------------- */

button, .btn {
  border-radius: 0;
  color: var(--primary);
  border: 1px solid var(--primary-disabled);
  text-transform: capitalize;
  font-family: var(--f-standard);
  font-size: 0.85em;
  vertical-align: middle;
  padding: 0.5em 1em;
  cursor: pointer;
  background: var(--primary-bg);
  outline: none;
  letter-spacing: 0.05em;
  transition: border-color 0.15s ease, color 0.15s ease;
}

button:hover, .btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

button:disabled, .btn:disabled {
  cursor: not-allowed;
  color: var(--disabled);
  border-color: var(--disabled);
}

button.primary, .btn-primary {
  background-color: var(--primary);
  color: var(--bg-black);
  border-color: var(--primary);
  font-weight: bold;
}

button.primary:hover, .btn-primary:hover {
  background-color: var(--fg-highlighted);
  border-color: var(--fg-highlighted);
}

button.danger, .btn-danger {
  color: var(--warning);
  border-color: var(--warning-disabled);
}

button.danger:hover, .btn-danger:hover {
  border-color: var(--warning);
}

button.secondary, .btn-secondary {
  color: var(--secondary);
  border-color: var(--secondary-disabled);
}

button.secondary:hover, .btn-secondary:hover {
  border-color: var(--secondary);
}

/* -- Forms ----------------------------------------------------------------- */

input, select, textarea {
  background: var(--primary-bg);
  border: 1px solid var(--primary-disabled);
  color: var(--fg);
  outline: none;
  font-family: var(--f-standard);
  font-size: 0.9em;
  padding: 0.5em;
  letter-spacing: 0.03em;
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

input::placeholder {
  color: var(--disabled);
}

label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.8em;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 0.3em;
}

.form-group {
  margin-bottom: 1em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
}

/* -- Tables ---------------------------------------------------------------- */

table {
  background-color: var(--primary-bg);
  border-spacing: 0;
  cursor: default;
  width: 100%;
}

table a, table a:visited {
  color: var(--primary);
  text-decoration: none;
}

thead {
  color: var(--primary-bg);
  background-color: var(--primary);
  text-transform: uppercase;
  line-height: 1.3em;
  user-select: none;
}

thead th {
  vertical-align: middle;
  font-weight: bold;
  padding: 0.4em 0.6em;
  text-align: left;
  border-left: 1px solid var(--primary-bg);
}

thead th:first-child {
  border-left: none;
}

tbody tr {
  color: var(--fg);
}

tbody tr:nth-child(odd) {
  background-color: var(--alt-primary-bg);
}

tbody tr:hover {
  background-color: var(--alt-primary-bg-hl);
}

td {
  line-height: 1.4em;
  padding: 0.3em 0.6em;
}

td.lbl {
  border: 1px solid var(--primary);
  text-transform: uppercase;
  color: var(--primary-bg);
  background-color: var(--primary);
  font-weight: bold;
}

td.val {
  border: 1px solid var(--primary);
}

/* -- Cards / Panels -------------------------------------------------------- */

.card {
  background-color: var(--primary-bg);
  border: 1px solid var(--primary-disabled);
  padding: 1em;
  margin-bottom: 1em;
}

.card-header {
  color: var(--primary);
  text-transform: uppercase;
  font-family: var(--f-title);
  font-size: 1em;
  padding-bottom: 0.5em;
  margin-bottom: 0.5em;
  border-bottom: 1px solid var(--primary-disabled);
}

.panel {
  border: 1px solid var(--primary);
  margin-bottom: 1em;
}

.panel-header {
  background-color: var(--primary);
  color: var(--bg-black);
  text-transform: uppercase;
  font-weight: bold;
  padding: 0.3em 0.6em;
  font-size: 0.9em;
  text-align: center;
}

.panel-body {
  background-color: var(--primary-bg);
  padding: 0.5em;
}

/* -- Section Headers (matching coriolis.io section bars) -------------------- */

.section-header {
  background-color: var(--primary);
  color: var(--bg-black);
  text-transform: uppercase;
  font-weight: bold;
  padding: 0.3em 0.6em;
  font-size: 0.85em;
  text-align: center;
  letter-spacing: 0.1em;
  margin-bottom: 0;
}

.section-body {
  background-color: var(--primary-bg);
  border: 1px solid var(--primary-disabled);
  border-top: none;
  padding: 1.25em;
}

/* -- Dashboard ------------------------------------------------------------- */

.dashboard {
  max-width: 800px;
  margin: 0 auto;
}

.dashboard > h2 {
  margin-bottom: 0.25em;
}

.dashboard > p {
  margin-top: 0;
}

.dashboard-section {
  margin-bottom: 1.5em;
}

.dashboard-section .section-body form input {
  width: 100%;
}

.dashboard-section .section-body form button {
  margin-top: 0.5em;
}

/* -- Stat Grid (for key/value pairs like the ship summary) ----------------- */

.stat-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0;
}

.stat-grid .stat-label {
  text-align: right;
  padding: 0.15em 0.5em 0.15em 0;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.85em;
}

.stat-grid .stat-value {
  text-align: left;
  padding: 0.15em 0 0.15em 0.5em;
  color: var(--fg);
}

.stat-grid .stat-value.primary {
  color: var(--primary);
}

.stat-grid .stat-value.warning {
  color: var(--warning);
}

.stat-grid .stat-value.secondary {
  color: var(--secondary);
}

/* -- API Key --------------------------------------------------------------- */

.api-key-row {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin-top: 0.5em;
}

.api-key-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.1em;
  letter-spacing: 0.15em;
  padding: 0.4em 0.75em;
  background: var(--bg-dark, #121212);
  border: 1px solid var(--border-dim, #333);
  color: var(--primary);
  user-select: all;
}

/* -- Alerts / Messages ----------------------------------------------------- */

.alert {
  padding: 0.75em 1em;
  margin-bottom: 1em;
  border: 1px solid;
  font-size: 0.9em;
}

.alert-info {
  border-color: var(--secondary-disabled);
  color: var(--secondary);
  background-color: var(--secondary-bg);
}

.alert-warning {
  border-color: var(--warning-disabled);
  color: var(--warning);
  background-color: var(--warning-bg);
}

.alert-success {
  border-color: var(--success);
  color: var(--success);
  background-color: rgba(40, 60, 30, 0.5);
}

.alert-error {
  border-color: red;
  color: red;
  background-color: rgba(60, 10, 10, 0.5);
}

/* -- Announcement (matching coriolis.io) ----------------------------------- */

.announcement-container {
  display: flex;
  align-items: center;
  padding-top: 10px;
  justify-content: center;
  flex-flow: row wrap;
}

.announcement {
  border: 1px solid var(--secondary);
  padding: 10px;
  margin: 5px;
  color: var(--fg);
}

/* -- Utility Classes ------------------------------------------------------- */

.text-primary   { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-warning   { color: var(--warning); }
.text-muted     { color: var(--muted); }
.text-disabled  { color: var(--disabled); }
.text-success   { color: var(--success); }
.text-fg        { color: var(--fg); }

.bg-primary     { background-color: var(--primary-bg); }
.bg-black       { background-color: var(--bg-black); }

.uppercase      { text-transform: uppercase; }
.capitalize     { text-transform: capitalize; }
.text-center    { text-align: center; }
.text-right     { text-align: right; }
.text-left      { text-align: left; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5em; }
.mt-2 { margin-top: 1em; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5em; }
.mb-2 { margin-bottom: 1em; }
.p-1  { padding: 0.5em; }
.p-2  { padding: 1em; }

.hidden { display: none; }

/* -- Scrollbar Styling ----------------------------------------------------- */

::-webkit-scrollbar {
  width: 0.5em;
}

::-webkit-scrollbar-track {
  background-color: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--warning-disabled);
}

/* -- Django Messages (if using Django messages framework) ------------------- */

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 1em 0;
}

.messages li {
  padding: 0.75em 1em;
  margin-bottom: 0.5em;
  border: 1px solid;
}

.messages li.success {
  border-color: var(--success);
  color: var(--success);
  background-color: rgba(40, 60, 30, 0.5);
}

.messages li.error {
  border-color: red;
  color: red;
  background-color: rgba(60, 10, 10, 0.5);
}

.messages li.warning {
  border-color: var(--warning-disabled);
  color: var(--warning);
  background-color: var(--warning-bg);
}

.messages li.info {
  border-color: var(--secondary-disabled);
  color: var(--secondary);
  background-color: var(--secondary-bg);
}

/* -- Auth / Login Forms ---------------------------------------------------- */

.auth-container {
  max-width: 400px;
  margin: 2em auto;
  text-align: left;
}

.auth-container h2 {
  text-align: center;
  margin-bottom: 1em;
}

.auth-container form {
  background-color: var(--primary-bg);
  border: 1px solid var(--primary-disabled);
  padding: 1.5em;
}

.auth-container form input {
  width: 100%;
  margin-bottom: 1em;
}

.auth-container form button,
.auth-container form .btn {
  width: 100%;
  margin-top: 0.5em;
}

.auth-container .auth-footer {
  text-align: center;
  margin-top: 1em;
  font-size: 0.85em;
  color: var(--muted);
}

.auth-container .auth-footer a {
  color: var(--secondary);
}

.auth-container .auth-footer a:hover {
  color: var(--primary);
}

/* -- Form Help Text & Field Errors ----------------------------------------- */

.help-text {
  display: block;
  margin-top: 0.3em;
  font-size: 0.8em;
  color: var(--muted);
  font-style: italic;
}

.field-errors {
  list-style: none;
  padding: 0;
  margin: 0.3em 0 0 0;
}

.field-errors li {
  color: var(--warning);
  font-size: 0.8em;
}

/* -- Responsive ------------------------------------------------------------ */

@media only screen and (max-width: 1000px) {
  header {
    padding: 0 0.5em;
  }

  .nav-btn {
    font-size: 0.75em;
    padding: 0 0.5em;
  }

  .user-nav {
    gap: 0.75em;
    font-size: 0.8em;
  }
}

@media only screen and (max-width: 640px) {
  header {
    padding: 0 0.25em;
  }

  .header-left {
    gap: 0.5em;
  }

  .coriolis-logo svg {
    width: 22px;
    height: 22px;
  }

  .nav-btn {
    font-size: 0.7em;
    padding: 0 0.35em;
    letter-spacing: 0.04em;
  }

  .user-nav {
    gap: 0.5em;
    font-size: 0.75em;
  }

  main {
    padding: 0.75em;
  }
}

@media only screen and (max-width: 400px) {
  main {
    padding: 0.5em;
  }
}

/* ── Ship table ──────────────────────────────────────────── */
.ship-table {
  width: 100%;
  border-collapse: collapse;
}

.ship-table th,
.ship-table td {
  padding: 0.5em 0.75em;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ship-table thead {
  background: transparent;
}

.ship-table thead th {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--primary);
  border-left: none;
}

.ship-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ship-table tr.current-ship {
  background: rgba(255, 140, 13, 0.06);
}

.badge {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2em 0.55em;
  border-radius: 3px;
}

.badge.active {
  color: #000;
  background: var(--primary);
}

/* ── Generic data table ──────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead {
  background: transparent;
}

.data-table th,
.data-table td {
  padding: 0.45em 0.75em;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table thead th {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--primary);
  border-left: none;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .center {
  text-align: center;
}

/* ── Module page ─────────────────────────────────────────── */
.module-ship-section {
  margin-bottom: 2em;
}

.module-ship-section .section-header {
  margin-bottom: 0;
  border-radius: 4px 4px 0 0;
}

.module-ship-section .section-body {
  padding: 0;
}

.module-table {
  font-size: 0.9em;
}

/* ── Filter Row (inside thead) ────────────────────────────── */
.filter-row th {
  border-bottom: none !important;
  padding-top: 0.5em;
  padding-bottom: 0.3em;
  vertical-align: bottom;
}

.filter-row select {
  width: 100%;
  padding: 0.35em 0.4em;
  font-size: 0.85em;
}

.filter-row select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.filter-row button {
  padding: 0.35em 0.7em;
  font-size: 0.8em;
  white-space: nowrap;
}

/* ── Materials page ──────────────────────────────────────── */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5em;
}

.material-category .section-header {
  margin-bottom: 0;
  border-radius: 4px 4px 0 0;
}

.material-category .section-body {
  padding: 0;
}

.material-table {
  font-size: 0.9em;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3em 1em;
  color: var(--muted);
}

.empty-state p:first-child {
  font-size: 1.1em;
  color: var(--fg);
  margin-bottom: 0.5em;
}

.empty-state a {
  color: var(--secondary);
}

/* ── Builds page ─────────────────────────────────────────── */
.build-table {
  font-size: 0.9em;
}

.build-table .build-desc {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.3em 0.5em;
  font-size: 0.95em;
  border-radius: 3px;
}

.build-table .build-desc:focus {
  border-color: var(--secondary);
  outline: none;
}

.build-table .build-ship-select {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 0.3em 0.4em;
  font-size: 0.85em;
}

.build-actions-cell {
  text-align: center;
  white-space: nowrap;
}

.build-save-btn,
.build-unlink-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.3em 0.6em;
  cursor: pointer;
  border-radius: 3px;
  font-size: 1em;
}

.build-save-btn:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

.build-unlink-btn:hover {
  border-color: #c0392b;
  color: #c0392b;
}

/* ── Material Grade Icons (inline SVG) ───────────────────── */
.grade-icon {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  color: var(--primary);
}

.grade-icon-unknown {
  opacity: 0.35;
}
