/* ============================================
   VULCAN TRADER PORTAL — BRAND STYLESHEET
   Colours: Red #DA0211 | Black #333333 | White #ffffff
   Font: Lato, Sans-serif
   Mobile-first, PWA app feel
   ============================================ */

/* --- Google Font Import --- */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700;900&display=swap');

/* --- CSS Variables --- */
:root {
  /* Brand colours */
  --red:        #DA0211;
  --red-dark:   #b30000;
  --red-light:  #ff1a2a;
  --black:      #333333;
  --black-deep: #1a1a1a;
  --white:      #ffffff;

  /* UI colours */
  --bg:         #1a1a1a;
  --bg-card:    #2a2a2a;
  --bg-input:   #222222;
  --border:     #3a3a3a;
  --border-light: #444444;
  --text:       #ffffff;
  --text-muted: #aaaaaa;
  --text-dim:   #777777;
  --success:    #2ecc71;
  --warning:    #f39c12;
  --danger:     #DA0211;

  /* Spacing */
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   16px;
  --space-lg:   24px;
  --space-xl:   32px;
  --space-2xl:  48px;

  /* Typography */
  --font:       'Lato', sans-serif;
  --text-xs:    11px;
  --text-sm:    13px;
  --text-base:  15px;
  --text-md:    17px;
  --text-lg:    20px;
  --text-xl:    24px;
  --text-2xl:   30px;
  --text-3xl:   38px;

  /* Layout */
  --radius:     8px;
  --radius-lg:  14px;
  --radius-full: 999px;
  --nav-height: 64px;        /* top header */
  --bottom-nav: 64px;        /* bottom tab bar */
  --max-width:  480px;       /* max mobile content width */
  --sidebar-width: 220px;    /* left nav on large displays */
  --shadow:     0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg:  0 4px 24px rgba(0,0,0,0.6);
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: var(--font);
  font-size: var(--text-base);
}

/* --- App Shell Layout --- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
}

/* Main scrollable content area — sits between top nav and bottom nav */
.main {
  flex: 1;
  overflow-y: auto;
  padding: var(--nav-height) var(--space-md) var(--bottom-nav);
  padding-bottom: calc(var(--bottom-nav) + var(--space-md));
}

/* Full-screen pages (login etc) with no nav */
.main--full {
  padding: 0;
  overflow: hidden;
}

/* --- Top Header / Nav --- */
.header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--nav-height);
  background: var(--black-deep);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  z-index: 100;
  box-shadow: var(--shadow);
}

.header__logo {
  height: 32px;
  width: auto;
}

.header__title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.02em;
}

.header__action {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 20px;
  border-radius: var(--radius);
  transition: color 0.2s;
}

.header__action:active {
  color: var(--white);
}

/* --- Bottom Tab Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--bottom-nav);
  background: var(--black-deep);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-dim);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.2s;
  position: relative;
}

.nav-tab i {
  font-size: 20px;
}

.nav-tab.active {
  color: var(--red);
}

.nav-tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--red);
  border-radius: 0 0 var(--radius) var(--radius);
}

.nav-tab:active {
  color: var(--red-light);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px var(--space-lg);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: all 0.18s;
  width: 100%;
  text-align: center;
}

.btn--primary {
  background: var(--red);
  color: var(--white);
}

.btn--primary:active {
  background: var(--red-dark);
  transform: scale(0.98);
}

.btn--secondary {
  background: var(--bg-card);
  color: var(--white);
  border: 1px solid var(--border-light);
}

.btn--secondary:active {
  background: var(--border);
  transform: scale(0.98);
}

.btn--ghost {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}

.btn--ghost:active {
  background: rgba(218, 2, 17, 0.1);
}

.btn--sm {
  padding: 9px var(--space-md);
  font-size: var(--text-sm);
  width: auto;
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.card--flat {
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md);
}

/* --- Form Fields --- */
.field {
  margin-bottom: var(--space-md);
}

.field__label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.field__input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--white);
  padding: 13px var(--space-md);
  font-size: var(--text-base);
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.field__input:focus {
  outline: none;
  border-color: var(--red);
}

.field__input::placeholder {
  color: var(--text-dim);
}

.field__error {
  font-size: var(--text-xs);
  color: var(--red);
  margin-top: var(--space-xs);
}

/* --- Page Titles --- */
.page-title {
  font-size: var(--text-xl);
  font-weight: 900;
  color: var(--white);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-xs);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* --- Section Headers --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.section-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.section-link {
  font-size: var(--text-sm);
  color: var(--red);
  font-weight: 700;
}

/* --- Stat / Summary Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.stat-card__label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.stat-card__value {
  font-size: var(--text-2xl);
  font-weight: 900;
  color: var(--white);
  line-height: 1;
}

.stat-card__value--red {
  color: var(--red);
}

.stat-card__sub {
  font-size: var(--text-xs);
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Badges / Status --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge--success {
  background: rgba(46, 204, 113, 0.15);
  color: var(--success);
}

.badge--warning {
  background: rgba(243, 156, 18, 0.15);
  color: var(--warning);
}

.badge--danger {
  background: rgba(218, 2, 17, 0.15);
  color: var(--red);
}

.badge--neutral {
  background: var(--border);
  color: var(--text-muted);
}

/* --- Divider --- */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

/* --- Progress Bar (rewards) --- */
.progress {
  background: var(--border);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
  margin: var(--space-sm) 0;
}

.progress__fill {
  height: 100%;
  background: var(--red);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* --- List Items --- */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-sm);
  transition: border-color 0.2s;
}

.list-item:active {
  border-color: var(--red);
}

.list-item__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
  color: var(--text-muted);
}

.list-item__body {
  flex: 1;
  min-width: 0;
}

.list-item__title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item__sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.list-item__right {
  text-align: right;
  flex-shrink: 0;
}

.list-item__price {
  font-size: var(--text-base);
  font-weight: 900;
  color: var(--white);
}

.list-item__pts {
  font-size: var(--text-xs);
  color: var(--red);
  font-weight: 700;
}

/* --- Checkbox / Toggle (extras) --- */
.checkbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: border-color 0.2s;
}

.checkbox-item:has(input:checked) {
  border-color: var(--red);
}

.checkbox-item__label {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--white);
}

.checkbox-item__price {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.checkbox-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--red);
  cursor: pointer;
  flex-shrink: 0;
}

/* --- Toast Notification --- */
.toast {
  position: fixed;
  top: calc(var(--nav-height) + var(--space-md));
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--white);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  white-space: nowrap;
  max-width: calc(var(--max-width) - var(--space-xl));
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--success { border-color: var(--success); color: var(--success); }
.toast--error   { border-color: var(--red); color: var(--red); }

/* --- Empty State --- */
.empty {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
}

.empty__icon {
  font-size: 48px;
  color: var(--text-dim);
  margin-bottom: var(--space-md);
}

.empty__title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--white);
  margin-bottom: var(--space-sm);
}

.empty__sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* --- Loading Spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: var(--space-lg) auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Utility Classes --- */
.text-red    { color: var(--red); }
.text-muted  { color: var(--text-muted); }
.text-white  { color: var(--white); }
.text-sm     { font-size: var(--text-sm); }
.text-lg     { font-size: var(--text-lg); }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 900; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-sm       { margin-top: var(--space-sm); }
.mt-md       { margin-top: var(--space-md); }
.mt-lg       { margin-top: var(--space-lg); }
.mb-sm       { margin-bottom: var(--space-sm); }
.mb-md       { margin-bottom: var(--space-md); }
.mb-lg       { margin-bottom: var(--space-lg); }
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-sm      { gap: var(--space-sm); }
.gap-md      { gap: var(--space-md); }
.w-full      { width: 100%; }
.hidden      { display: none !important; }

/* --- Tablet Breakpoint --- */
/* Between phone and large-display sizes, just center the app like a phone frame */
@media (min-width: 520px) and (max-width: 959px) {
  body {
    background: #111111;
  }

  .app {
    box-shadow: 0 0 60px rgba(0,0,0,0.8);
  }

  .header,
  .bottom-nav {
    width: var(--max-width);
  }
}

/* ============================================
   LARGE DISPLAY BREAKPOINT
   Reshapes the mobile app-shell into a desktop
   layout: bottom tab bar becomes a left sidebar,
   content widens beyond the phone-frame constraint.
   ============================================ */
@media (min-width: 960px) {
  .app {
    max-width: none;
    box-shadow: none;
    min-height: 100vh;
  }

  .header {
    left: var(--sidebar-width);
    transform: none;
    width: calc(100% - var(--sidebar-width));
    max-width: none;
    padding: 0 var(--space-xl);
  }

  .bottom-nav {
    top: 0;
    bottom: 0;
    left: 0;
    transform: none;
    width: var(--sidebar-width);
    height: 100vh;
    max-width: none;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    padding: calc(var(--nav-height) + var(--space-lg)) 0 var(--space-lg);
    border-top: none;
    border-right: 1px solid var(--border);
  }

  .nav-tab {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-md);
    padding: 12px var(--space-lg);
    font-size: var(--text-sm);
    text-transform: none;
    letter-spacing: normal;
  }

  .nav-tab i {
    font-size: 20px;
  }

  .nav-tab.active::before {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 3px;
    height: auto;
    border-radius: 0 var(--radius) var(--radius) 0;
  }

  .main {
    margin-left: var(--sidebar-width);
    max-width: 1040px;
    padding: calc(var(--nav-height) + var(--space-xl)) var(--space-xl) var(--space-xl);
  }

  .main--full {
    margin-left: 0;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
