/* ─────────────────────────────────────────────
   Pitlog — Dark Theme CSS
   Accent: #e63946 (red) → #f4a261 (orange)
───────────────────────────────────────────── */

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

:root {
  --bg:        #0f0f1a;
  --bg-card:   #16162a;
  --bg-input:  #1e1e35;
  --bg-hover:  #1e1e3a;
  --border:    #2a2a45;
  --text:      #e8e8f0;
  --text-muted:#9090b0;
  --accent1:   #e63946;
  --accent2:   #f4a261;
  --accent-g:  linear-gradient(90deg, #e63946, #f4a261);
  --success:   #2ecc71;
  --warning:   #f39c12;
  --danger:    #e74c3c;
  --info:      #3498db;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --transition:150ms ease;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--accent1); }
img { max-width: 100%; height: auto; display: block; }
ul { list-style: none; }

/* ── Typography ─────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
h3 { font-size: 1.2rem; }
.text-muted    { color: var(--text-muted); }
.text-accent   { background: var(--accent-g); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }

/* ── Layout ─────────────────────────────────── */
.container { width: 100%; max-width: 1100px; margin-inline: auto; padding-inline: 1rem; }
.main { flex: 1; padding: 2rem 0; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { margin-bottom: .25rem; }
.flex { display: flex; align-items: center; gap: .75rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* ── Navbar ─────────────────────────────────── */
.navbar {
  background: rgba(15, 15, 26, .95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; }
.nav-logo { width: 32px; height: 32px; }
.brand-pit  { font-size: 1.4rem; font-weight: 800; background: var(--accent-g); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.brand-log  { font-size: 1.4rem; font-weight: 400; color: var(--text); }
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-link { color: var(--text-muted); font-size: .95rem; transition: color var(--transition); }
.nav-link:hover, .nav-link.active { color: var(--accent2); }
.nav-ai { color: var(--accent1) !important; font-weight: 600; }
.nav-user { display: flex; align-items: center; gap: .5rem; }
.nav-name { font-size: .85rem; color: var(--text-muted); }
.btn-logout { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: .25rem .7rem; border-radius: 6px; cursor: pointer; font-size: .85rem; transition: all var(--transition); }
.btn-logout:hover { border-color: var(--accent1); color: var(--accent1); }
.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 4px; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: all var(--transition); }
.inline { display: inline; }

/* ── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary  { background: var(--accent-g); color: #fff; }
.btn-primary:hover { opacity: .88; transform: translateY(-1px); color: #fff; }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent2); color: var(--accent2); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-input); color: var(--text); }
.btn-sm       { padding: .35rem .8rem; font-size: .85rem; }
.btn-lg       { padding: .8rem 1.8rem; font-size: 1.05rem; }
.btn-icon     { padding: .5rem; border-radius: 8px; }
.btn[disabled], .btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ── Cards ──────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color var(--transition), transform var(--transition);
}
.card:hover { border-color: rgba(230,57,70,.4); }
.card-link:hover { transform: translateY(-2px); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-title  { font-size: 1rem; font-weight: 700; color: var(--text); }
.card-body   { }
.card-footer { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.card-accent { border-left: 3px solid var(--accent1); }

/* ── Car Card ───────────────────────────────── */
.car-card { position: relative; overflow: hidden; }
.car-card-img { width: 100%; height: 160px; object-fit: cover; border-radius: 8px; margin-bottom: .75rem; background: var(--bg-input); }
.car-card-img-placeholder { width: 100%; height: 160px; background: var(--bg-input); border-radius: 8px; margin-bottom: .75rem; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }
.car-card-make  { font-size: 1.15rem; font-weight: 800; }
.car-card-model { font-size: .95rem; color: var(--text-muted); }
.car-card-plate { font-family: monospace; font-size: .85rem; background: var(--bg-input); padding: .2rem .5rem; border-radius: 4px; color: var(--accent2); }
.car-card-meta  { display: flex; justify-content: space-between; align-items: center; margin-top: .75rem; flex-wrap: wrap; gap: .5rem; }
.car-card-km    { font-size: .85rem; color: var(--text-muted); }
.car-card-cost  { font-size: .85rem; color: var(--success); font-weight: 600; }
.badge-public   { position: absolute; top: .75rem; right: .75rem; background: var(--accent-g); color: #fff; font-size: .7rem; padding: .2rem .5rem; border-radius: 20px; font-weight: 700; }

/* ── Stat boxes ─────────────────────────────── */
.stat-box { text-align: center; padding: 1rem; }
.stat-value { font-size: 1.8rem; font-weight: 800; background: var(--accent-g); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Forms ──────────────────────────────────── */
.form-group  { margin-bottom: 1rem; }
.form-label  { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .35rem; color: var(--text-muted); }
.form-control {
  display: block;
  width: 100%;
  padding: .6rem .9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  transition: border-color var(--transition);
  appearance: none;
}
.form-control:focus { outline: none; border-color: var(--accent1); background: var(--bg-hover); }
.form-control::placeholder { color: var(--text-muted); opacity: .6; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%239090b0'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.5rem; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint   { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }
.form-row    { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-check  { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.form-check input[type="checkbox"] { accent-color: var(--accent1); width: 16px; height: 16px; }

/* ── Tables ─────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th { background: var(--bg-input); padding: .75rem 1rem; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); white-space: nowrap; border-bottom: 1px solid var(--border); text-align: left; }
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover); }
.td-muted { color: var(--text-muted); }

/* ── Alerts ─────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; border: 1px solid; }
.alert-success { background: rgba(46,204,113,.1); border-color: rgba(46,204,113,.3); color: #2ecc71; }
.alert-error   { background: rgba(231,76,60,.1);  border-color: rgba(231,76,60,.3);  color: #e74c3c; }
.alert-warning { background: rgba(243,156,18,.1); border-color: rgba(243,156,18,.3); color: #f39c12; }
.alert-info    { background: rgba(52,152,219,.1); border-color: rgba(52,152,219,.3); color: #3498db; }

/* ── Tabs ───────────────────────────────────── */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab-btn { background: none; border: none; padding: .6rem 1rem; color: var(--text-muted); font-size: .9rem; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--transition); font-weight: 600; }
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--accent1); border-bottom-color: var(--accent1); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Reminder badges ────────────────────────── */
.reminder-item { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.reminder-item:last-child { border-bottom: none; }
.reminder-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: .1rem; }
.reminder-label { font-weight: 600; font-size: .95rem; }
.reminder-meta  { font-size: .8rem; color: var(--text-muted); }
.reminder-status { font-size: .75rem; padding: .15rem .5rem; border-radius: 20px; font-weight: 700; }
.status-ok      { background: rgba(46,204,113,.15); color: var(--success); }
.status-soon    { background: rgba(243,156,18,.15);  color: var(--warning); }
.status-overdue { background: rgba(231,76,60,.15);   color: var(--danger); }

/* ── AI Chat ────────────────────────────────── */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 400px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.chat-msg { max-width: 80%; padding: .7rem 1rem; border-radius: 12px; font-size: .9rem; line-height: 1.5; }
.chat-msg-user { background: var(--accent1); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg-ai   { background: var(--bg-input); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.chat-msg-ai p { margin-bottom: .5rem; }
.chat-msg-ai p:last-child { margin-bottom: 0; }
.chat-input-row { display: flex; gap: .5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.chat-input { flex: 1; }
.chat-typing { color: var(--text-muted); font-size: .85rem; padding: .5rem 1rem; }

/* ── Hero (public index) ────────────────────── */
.hero {
  padding: 5rem 0 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
/* Background image layer — blur + dim */
.hero-bg {
  position: absolute;
  inset: 0;
  background-image: var(--hero-img, none);
  background-size: cover;
  background-position: center;
  filter: blur(4px) brightness(.35);
  transform: scale(1.05); /* covers blur edges */
  z-index: 0;
}
/* Dark gradient overlay над снимката */
.hero-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 110% 70% at 50% 110%, rgba(230,57,70,.22) 0%, transparent 60%),
    linear-gradient(to bottom, rgba(15,15,26,.55) 0%, rgba(15,15,26,.2) 50%, rgba(15,15,26,.7) 100%);
  z-index: 1;
}
/* Speed lines */
.hero-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 79px,
    rgba(255,255,255,.018) 80px
  );
  pointer-events: none;
}
/* Pit lane checkered edge at bottom */
.hero-overlay::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: repeating-linear-gradient(
    90deg,
    var(--accent1) 0px, var(--accent1) 12px,
    transparent   12px, transparent  24px
  );
  opacity: .6;
}
.hero-inner { position: relative; z-index: 2; }
.hero-sub { color: var(--text-muted); font-size: 1.1rem; margin: 1rem auto; max-width: 550px; }
.hero-actions { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-top: 2rem; }
.hero-stripe { width: 80px; height: 4px; background: var(--accent-g); border-radius: 2px; margin: 1rem auto 0; }

/* ── QR / Public car ────────────────────────── */
.qr-wrap { text-align: center; padding: 1rem; }
.qr-wrap canvas, .qr-wrap img { margin: .5rem auto; }

/* ── Progress bar ───────────────────────────── */
.progress { background: var(--bg-input); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent-g); border-radius: 99px; transition: width .4s ease; }

/* ── Charts placeholder ─────────────────────── */
.chart-container { position: relative; height: 220px; }

/* ── Admin table ────────────────────────────── */
.admin-actions { display: flex; gap: .5rem; }

/* ── Footer ─────────────────────────────────── */
.footer { border-top: 1px solid var(--border); padding: 1.5rem 0; text-align: center; color: var(--text-muted); font-size: .85rem; margin-top: auto; }

/* ── Utility ────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.w-100 { width: 100%; }
.d-none { display: none; }
.d-flex { display: flex; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Loading spinner ────────────────────────── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent1); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Divider ────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.divider-text { display: flex; align-items: center; gap: 1rem; color: var(--text-muted); font-size: .85rem; margin: 1.5rem 0; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; border-top: 1px solid var(--border); }

/* ── Chat markdown renderer ─────────────────── */
.chat-msg-ai p         { margin: 0 0 .55rem; line-height: 1.65; }
.chat-msg-ai p:last-child { margin-bottom: 0; }
.chat-msg-ai .md-h1   { font-size: 1.05rem; font-weight: 800; color: var(--accent2); margin: .8rem 0 .3rem; padding-bottom: .2rem; border-bottom: 1px solid var(--border); }
.chat-msg-ai .md-h2   { font-size: .98rem;  font-weight: 700; color: var(--accent2); margin: .65rem 0 .25rem; }
.chat-msg-ai .md-h3   { font-size: .93rem;  font-weight: 700; color: var(--text);    margin: .5rem 0 .2rem; }
.chat-msg-ai .md-list { margin: .35rem 0 .5rem 1.3rem; display: flex; flex-direction: column; gap: .2rem; }
.chat-msg-ai ul.md-list { list-style: disc; }
.chat-msg-ai ol.md-list { list-style: decimal; }
.chat-msg-ai .md-list li { line-height: 1.55; }
.chat-msg-ai .md-pre  { background: rgba(0,0,0,.35); border: 1px solid var(--border); padding: .65rem .85rem; border-radius: 8px; font-size: .82rem; overflow-x: auto; margin: .5rem 0; white-space: pre; }
.chat-msg-ai .md-code { background: rgba(0,0,0,.3); padding: .1rem .35rem; border-radius: 4px; font-size: .83rem; font-family: monospace; color: var(--accent2); }
.chat-msg-ai .md-hr   { border: none; border-top: 1px solid var(--border); margin: .6rem 0; }
.chat-msg-ai strong   { font-weight: 700; color: #fff; }
.chat-msg-ai em       { font-style: italic; color: var(--text-muted); }

/* ── AI text response (stats tab) ───────────── */
.ai-response {
  font-size: .88rem;
  line-height: 1.65;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Photo AI page ───────────────────────────── */
.photo-drop { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 2.5rem; text-align: center; cursor: pointer; transition: border-color var(--transition), background var(--transition); }
.photo-drop:hover, .photo-drop.dragover { border-color: var(--accent1); background: rgba(230,57,70,.05); }
.photo-drop-icon { font-size: 3rem; margin-bottom: .5rem; }
.photo-preview img { max-height: 260px; border-radius: var(--radius); margin: 1rem auto; object-fit: contain; }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 640px) {
  .nav-links { display: none; flex-direction: column; align-items: flex-start; position: absolute; top: 60px; left: 0; right: 0; background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 1rem; gap: .75rem; }
  .nav-links.open { display: flex; }
  .nav-toggle { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero { padding: 3rem 0 2rem; }
  .chat-msg { max-width: 95%; }
  .flex-between { flex-direction: column; align-items: flex-start; }
  table { font-size: .8rem; }
  thead th, tbody td { padding: .5rem .6rem; }
}
