/*
  RWEngine styles.css

  Purpose:
  - Contains all visual styling for the Netlify frontend.
  - Keeping styles separate from index.html makes layout edits easier.
  - No backend or Torn API logic belongs in this file.
*/

/* =========================
   GLOBAL BASE STYLES
========================= */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background:
    linear-gradient(rgba(8, 8, 8, .92), rgba(8, 8, 8, .96)),
    #0b0b0b;
  color: #e5e7eb;
}

.hidden { display: none !important; }

/* =========================
   LOGIN PAGE
========================= */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #1f1f1f;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
}

.login-card h1 {
  margin: 0 0 8px;
  color: white;
  font-size: 32px;
  font-weight: 500;
}

.login-card p {
  margin: 0 0 20px;
  color: #94a3b8;
  font-size: 14px;
}

.login-error {
  margin-top: 12px;
  color: #fca5a5;
  font-size: 13px;
}

/* =========================
   TOP NAVIGATION
========================= */

.topbar {
  height: 42px;
  background: #1f1f1f;
  border-bottom: 1px solid #333;
  box-shadow: 0 2px 8px rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 800; color: white; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
}

.nav-tabs {
  display: flex;
  gap: 8px;
}

.nav-tab {
  width: auto;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: #d1d5db;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
}

.nav-tab:hover,
.nav-tab.active {
  color: white;
  background: #2b2b2b;
}

.small-button {
  width: auto;
  padding: 6px 10px;
}

/* =========================
   PAGE LAYOUT
========================= */

.page {
  display: flex;
  justify-content: center;
}

.page-inner {
  width: 100%;
  max-width: 1180px;
  padding: 28px 24px;
  margin-right: auto;
  margin-left: 14%;
}

.tab-page { display: none; }
.tab-page.active { display: block; }

.hero { margin-bottom: 20px; }

.hero h1 {
  font-size: 42px;
  font-weight: 400;
  margin: 0 0 6px;
  color: white;
}

.hero p {
  margin: 0;
  color: #cbd5e1;
  font-weight: 600;
  font-size: 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items: start;
}

.panel,
.sidebar {
  background: #1f1f1f;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}

.sidebar { align-self: start; }

.panel-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 14px;
  color: white;
}

/* =========================
   FORMS AND CONTROLS
========================= */

.control { margin-bottom: 13px; }

label {
  display: block;
  font-size: 12px;
  color: #cbd5e1;
  margin-bottom: 5px;
  font-weight: 700;
}

input,
select,
textarea,
button {
  width: 100%;
  padding: 8px 9px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #111;
  color: white;
  font-size: 13px;
  font-family: inherit;
}

textarea { resize: vertical; }

input:disabled {
  color: #94a3b8;
  background: #181818;
}

button {
  background: #2b2b2b;
  cursor: pointer;
  font-weight: 800;
}

button:hover { background: #3a3a3a; }

/*
  API key visibility toggle.
  Used in Settings for the saved API key field.
*/
.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
}

.icon-button {
  width: 42px;
  flex: 0 0 42px;
  padding: 8px;
}

/* =========================
   SUMMARY CARDS
========================= */

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.summary-card {
  background: #262626;
  border: 1px solid #333;
  padding: 12px;
  border-radius: 8px;
}

.summary-card .label {
  color: #94a3b8;
  font-size: 11px;
  margin: 0;
}

.summary-card .value {
  font-size: 20px;
  font-weight: 800;
  margin-top: 4px;
  color: white;
}

/* =========================
   DASHBOARD TABLE
========================= */

.table-wrap {
  width: 100%;
  background: #1f1f1f;
  border: 1px solid #333;
  border-radius: 10px;
  overflow: auto;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}

table {
  width: 100%;
  min-width: 1000px;
  border-collapse: collapse;
  table-layout: fixed;
}

thead { background: #202020; }

th, td {
  padding: 10px 12px;
  font-size: 13px;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  color: #dbeafe;
  font-weight: 800;
  text-align: left;
  border-bottom: 1px solid #444;
  cursor: pointer;
  user-select: none;
}

th:hover { background: #2b2b2b; }

td {
  color: #e5e7eb;
  border-bottom: 1px solid rgba(75, 85, 99, .45);
}

tbody tr:hover { background: #2b2b2b; }

th:nth-child(1), td:nth-child(1) { width: 60px; text-align: right; }
th:nth-child(2), td:nth-child(2) { width: 220px; text-align: left; }
th:nth-child(3), td:nth-child(3) { width: 90px; text-align: left; }

th:nth-child(n+4),
td:nth-child(n+4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rank { color: #94a3b8; font-weight: 800; }
.name { font-weight: 800; color: white; }
.positive { color: #6ee7b7; }
.negative { color: #fca5a5; }

.loading,
.error {
  padding: 16px;
  color: #cbd5e1;
}

.error { color: #fca5a5; }

/* =========================
   RESPONSIVE LAYOUT
========================= */

@media (max-width: 1000px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 34px; }
  .topbar { padding: 0 14px; }
  .page-inner { margin-left: 0; }
}
