/* ============================================================
   Tuning Freaks — Dark Theme
   ============================================================ */

:root {
  --tf-orange:     #ff6b00;
  --tf-orange-dim: #cc5500;
  --tf-bg:         #0e0e0e;
  --tf-bg-card:    #1a1a1a;
  --tf-bg-subtle:  #141414;
  --tf-border:     #2a2a2a;
  --tf-text:       #e0e0e0;
  --tf-text-muted: #888;
}

/* ── Base ──────────────────────────────────────────────────── */
body {
  background: var(--tf-bg);
  color: var(--tf-text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main, .container { flex: 1; }

.text-orange { color: var(--tf-orange) !important; }

/* ── Navbar ────────────────────────────────────────────────── */
.tf-navbar {
  background: rgba(14, 14, 14, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--tf-border);
}

.tf-brand {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--tf-text) !important;
  letter-spacing: -0.5px;
}

.tf-brand-icon {
  color: var(--tf-orange);
}

.tf-navbar .nav-link {
  color: var(--tf-text-muted) !important;
  font-size: 0.9rem;
  transition: color .2s;
}

.tf-navbar .nav-link:hover,
.tf-navbar .nav-link.active {
  color: var(--tf-text) !important;
}

/* ── Mobile nav overlay ────────────────────────────────────── */
@media (max-width: 991px) {
  #navMain {
    position: fixed;
    top: 57px;
    left: 0;
    right: 0;
    background: rgba(14, 14, 14, 0.98);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--tf-border);
    padding: 12px 16px 16px;
    margin-top: -3px;
    z-index: 1040;
    max-height: calc(100vh - 57px);
    overflow-y: auto;
  }
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-orange {
  background: var(--tf-orange);
  border-color: var(--tf-orange);
  color: #fff;
  font-weight: 600;
  transition: background .2s, transform .1s;
}

.btn-orange:hover {
  background: var(--tf-orange-dim);
  border-color: var(--tf-orange-dim);
  color: #fff;
}

.btn-orange:active { transform: scale(.97); }

/* ── Cards ─────────────────────────────────────────────────── */
.tf-card {
  background: var(--tf-bg-card);
  border: 1px solid var(--tf-border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform .2s, border-color .2s;
}

.tf-card:hover {
  transform: translateY(-3px);
  border-color: #3a3a3a;
}

.tf-card-img-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16/9;
}

.tf-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}

.tf-card:hover .tf-card-img {
  transform: scale(1.04);
}

.tf-card-body {
  padding: 14px 16px 16px;
}

.tf-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--tf-text);
}

/* ── Hero ──────────────────────────────────────────────────── */
.tf-hero {
  background: linear-gradient(135deg, #0e0e0e 0%, #1a0a00 50%, #0e0e0e 100%);
  text-align: center;
  padding: 80px 0 60px;
}

.tf-hero-content {
  padding-bottom: 0;
}

.tf-hero-title {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #fff 30%, var(--tf-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tf-hero-sub { font-size: 1.1rem; }

/* ── Section title ─────────────────────────────────────────── */
.tf-section-title {
  font-size: 1.4rem;
  font-weight: 800;
  position: relative;
  padding-left: 14px;
}

.tf-section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 70%;
  background: var(--tf-orange);
  border-radius: 4px;
}

/* ── Bg subtle ─────────────────────────────────────────────── */
.tf-bg-subtle { background: var(--tf-bg-subtle); }

/* ── Carousel ──────────────────────────────────────────────── */
.tf-carousel-img {
  height: 460px;
  object-fit: cover;
}

.tf-carousel-caption {
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  bottom: 0;
  left: 0;
  right: 0;
  padding: 40px 24px 24px;
  text-align: left;
}

/* ── Auth pages ────────────────────────────────────────────── */
.tf-auth-wrap {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.tf-auth-card {
  background: var(--tf-bg-card);
  border: 1px solid var(--tf-border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 480px;
}

.tf-auth-icon {
  font-size: 2.5rem;
  color: var(--tf-orange);
}

/* ── Divider ───────────────────────────────────────────────── */
.tf-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--tf-text-muted);
  font-size: 0.85rem;
}

.tf-divider::before,
.tf-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--tf-border);
}

/* ── Inputs ────────────────────────────────────────────────── */
.tf-input {
  background: #111 !important;
  border-color: var(--tf-border) !important;
  color: var(--tf-text) !important;
  border-radius: 8px;
}

.tf-input:focus {
  border-color: var(--tf-orange) !important;
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15) !important;
}

.tf-input::placeholder { color: var(--tf-text-muted) !important; }

/* ── Upload area ───────────────────────────────────────────── */
.tf-upload-area {
  border: 2px dashed var(--tf-border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s;
}

.tf-upload-area:hover {
  border-color: var(--tf-orange);
}

/* ── Badges ────────────────────────────────────────────────── */
.tf-badge {
  background: rgba(255, 107, 0, 0.15);
  color: var(--tf-orange);
  border: 1px solid rgba(255, 107, 0, 0.3);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 600;
}

.tf-featured-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--tf-orange);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

.tf-event-date-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.15);
}

/* ── Avatar ────────────────────────────────────────────────── */
.tf-avatar-sm {
  width: 36px;
  height: 36px;
  object-fit: cover;
}

.tf-avatar-lg {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border: 3px solid var(--tf-border);
}

.tf-avatar-edit {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: var(--tf-orange);
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
}

/* ── Car detail ────────────────────────────────────────────── */
.tf-stat-box {
  background: #111;
  border: 1px solid var(--tf-border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.tf-stat-icon { font-size: 1.4rem; color: var(--tf-orange); }
.tf-stat-value { font-size: 1.8rem; font-weight: 800; }
.tf-stat-label { font-size: 0.75rem; color: var(--tf-text-muted); text-transform: uppercase; letter-spacing: .5px; }

.tf-mods-text {
  color: var(--tf-text-muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.tf-car-main-img img {
  max-height: 420px;
  object-fit: cover;
}

.tf-thumb {
  width: 72px;
  height: 56px;
  object-fit: cover;
  cursor: pointer;
  opacity: 0.6;
  border: 2px solid transparent;
  transition: opacity .2s, border-color .2s;
}

.tf-thumb:hover,
.tf-thumb.active {
  opacity: 1;
  border-color: var(--tf-orange);
}

.tf-owner-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #111;
  border: 1px solid var(--tf-border);
  border-radius: 10px;
  padding: 14px;
}

/* ── Attend box ────────────────────────────────────────────── */
.tf-attend-box {
  background: #111;
  border: 1px solid var(--tf-border);
  border-radius: 12px;
  padding: 20px;
}

/* ── Dropdown ──────────────────────────────────────────────── */
.tf-dropdown {
  background: #1e1e1e;
  border: 1px solid var(--tf-border);
  border-radius: 10px;
  padding: 6px;
  min-width: 200px;
}

.tf-dropdown .dropdown-item {
  color: var(--tf-text-muted);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  transition: background .15s, color .15s;
}

.tf-dropdown .dropdown-item:hover {
  background: #2a2a2a;
  color: var(--tf-text);
}

/* ── Modal ─────────────────────────────────────────────────── */
.tf-modal {
  background: #1e1e1e;
  border: 1px solid var(--tf-border);
  border-radius: 14px;
  color: var(--tf-text);
}

/* ── Footer ────────────────────────────────────────────────── */
.tf-footer {
  background: #0a0a0a;
  border-top: 1px solid var(--tf-border);
}

/* ── Poll popup ────────────────────────────────────────────── */
.tf-poll-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,.7);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .2s ease;
}
.tf-poll-modal {
  background: #1a1a1a;
  border: 1px solid var(--tf-border);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.tf-poll-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--tf-border);
}
.tf-poll-close {
  background: none;
  border: none;
  color: var(--tf-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.tf-poll-close:hover { color: var(--tf-text); }
.tf-poll-body { padding: 16px 20px 20px; }
.tf-poll-options { display: flex; flex-direction: column; gap: 8px; }
.tf-poll-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #111;
  border: 1px solid var(--tf-border);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  text-align: left;
  width: 100%;
  color: var(--tf-text);
}
.tf-poll-option:hover {
  border-color: var(--tf-orange);
  background: #1f1f1f;
}
.tf-poll-option img {
  width: 70px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.tf-poll-option-info { display: flex; flex-direction: column; }
.tf-poll-result-row { margin-bottom: 4px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Toast notifications ───────────────────────────────────── */
.tf-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.tf-toast {
  pointer-events: all;
  min-width: 260px;
  max-width: 360px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: tfToastIn .25s ease;
  opacity: 1;
  transition: opacity .4s ease, transform .4s ease;
}
.tf-toast.tf-toast-success {
  background: #1a2e1a;
  border: 1px solid #2d5a2d;
  color: #6fcf6f;
}
.tf-toast.tf-toast-error {
  background: #2e1a1a;
  border: 1px solid #5a2d2d;
  color: #cf6f6f;
}
.tf-toast.tf-toast-hide {
  opacity: 0;
  transform: translateY(10px);
}
@keyframes tfToastIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--tf-orange); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 576px) {
  .tf-auth-card { padding: 24px; }
  .tf-carousel-img { height: 220px; }
}

/* ── Admin ─────────────────────────────────────────────────── */
.tf-admin-subnav {
  background: #0a0a0a;
  border-bottom: 1px solid var(--tf-border);
  padding: 8px 0;
}

.tf-admin-stat {
  background: var(--tf-bg-card);
  border: 1px solid var(--tf-border);
  border-radius: 12px;
  padding: 16px;
}

@media (min-width: 768px) {
  .tf-admin-stat { padding: 20px 24px; }
}

.tf-admin-stat-alert {
  border-color: rgba(255, 193, 7, .4);
}

.tf-admin-stat-icon { font-size: 1.6rem; }

.tf-admin-stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
}

@media (min-width: 768px) {
  .tf-admin-stat-icon  { font-size: 2rem; }
  .tf-admin-stat-value { font-size: 2.2rem; }
}

.tf-admin-stat-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--tf-text-muted);
  margin-top: 4px;
}

.table-dark td,
.table-dark th {
  border-color: var(--tf-border) !important;
}

.nav-tabs .nav-link {
  border-color: var(--tf-border);
  color: var(--tf-text-muted);
  background: transparent;
}

.nav-tabs .nav-link.active {
  background: var(--tf-bg-card);
  border-color: var(--tf-border);
  border-bottom-color: var(--tf-bg-card);
  color: var(--tf-text);
}

.nav-tabs .nav-link:hover:not(.active) {
  color: var(--tf-text);
  border-color: var(--tf-border);
}

/* ── Car slider ────────────────────────────────────────────── */
.cs-wrap {
  overflow: hidden;
  width: 100%;
  background: #080808;
}

.cs-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 25vw;
  grid-template-rows: 420px;
  width: max-content;
  animation: csScroll 40s linear infinite;
}

.cs-track:hover { animation-play-state: paused; }

@keyframes csScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.cs-item {
  position: relative;
  overflow: hidden;
  text-decoration: none;
  display: block;
  border-right: 3px solid #080808;
}

.cs-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s ease;
}

.cs-item:hover img { transform: scale(1.06); }

.cs-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 48px 14px 14px;
  background: linear-gradient(to top, rgba(0,0,0,.8), transparent);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cs-caption strong {
  color: #fff;
  font-size: .9rem;
  line-height: 1.3;
}

.cs-caption span {
  color: var(--tf-orange);
  font-size: .78rem;
}

@media (max-width: 991px) {
  .cs-track {
    grid-auto-columns: 50vw;
    grid-template-rows: 320px;
  }
}

@media (max-width: 575px) {
  .cs-track {
    grid-auto-columns: 100vw;
    grid-template-rows: 260px;
  }
}

/* ── Race / Compare ────────────────────────────────────────── */
.race-pick-card { transition: border-color .2s, transform .15s; cursor: pointer; }
.race-pick-card:hover { border-color: var(--tf-orange); transform: translateY(-3px); }

.race-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}

.race-car-side { display: flex; flex-direction: column; }
.race-car-side.text-end { align-items: flex-end; }

.race-car-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid var(--tf-border);
  display: block;
}

.race-vs {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--tf-orange);
  background: var(--tf-bg-card);
  border: 2px solid var(--tf-orange);
  border-radius: 50%;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.race-row {
  display: grid;
  grid-template-columns: 1fr 56px 1fr;
  gap: 8px;
  align-items: center;
}

.race-center-label {
  text-align: center;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--tf-text-muted);
  line-height: 1.2;
}

.race-side-a, .race-side-b {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.race-side-val { font-size: .82rem; line-height: 1; }

.race-bar-track {
  width: 100%;
  height: 10px;
  background: var(--tf-border);
  border-radius: 99px;
  overflow: hidden;
  display: flex;
}

/* Bar A: right-to-left — push bar to the right end */
.race-rtl { justify-content: flex-end; }

.race-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 1s cubic-bezier(.4,0,.2,1);
}

.race-bar-win  { background: var(--tf-orange); }
.race-bar-lose { background: #3a3a3a; }

.race-speed-bar {
  height: 8px;
  background: var(--tf-border);
  border-radius: 99px;
  overflow: hidden;
}

.race-speed-fill-a, .race-speed-fill-b {
  height: 100%;
  border-radius: 99px;
  transition: width 1.2s cubic-bezier(.4,0,.2,1);
}

.race-speed-fill-a { background: var(--tf-orange); }
.race-speed-fill-b { background: #4dabf7; }

.race-winner-badge { font-size: 3.5rem; line-height: 1; }

@media (max-width: 575px) {
  .race-header { grid-template-columns: 1fr auto 1fr; gap: 8px; }
  .race-car-img { max-height: 130px; }
}

/* ── Leaderboard ───────────────────────────────────────────── */
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--tf-border);
  transition: background .15s;
  color: var(--tf-text);
}

.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: rgba(255,107,0,.06); }
.lb-top3 { background: rgba(255,107,0,.04); }

.lb-rank {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  color: var(--tf-text-muted);
}

.lb-thumb {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid var(--tf-border);
}

.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.lb-info { flex: 1; min-width: 0; }

.lb-car-name {
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-owner {
  font-size: .75rem;
  color: var(--tf-text-muted);
}

.lb-value {
  font-size: 1rem;
  text-align: right;
  flex-shrink: 0;
}
