/* =========================================================
   Trailer74 — стили
   ========================================================= */
:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7280;
  --primary: #1d4ed8;
  --primary-d: #1746b0;
  --accent: #f59e0b;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(20,40,80,.06);
  --shadow-lg: 0 10px 30px rgba(20,40,80,.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  overscroll-behavior-y: none;
  touch-action: pan-y;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- HEADER ---------- */
#site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 20px; flex-wrap: wrap;
}
.brand { font-size: 20px; font-weight: 800; color: var(--primary); }
.nav { display: flex; gap: 18px; }
.nav a { color: var(--text); font-weight: 500; }
.nav a.active, .nav a:hover { color: var(--primary); text-decoration: none; }
.user-area { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit;
  transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f0f2f5; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #c87f08; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b21f1f; }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- HERO ---------- */
/* Глубокий многослойный серый фон: пятна света, виньетка,
   «инженерная» сетка, диагональные блики и плотные тени. */
.hero {
  position: relative;
  color: #fff;
  padding: 28px 0 18px;
  background-color: #181b22;
  background-image:
    /* 1. верхнее правое холодное «окно» света */
    radial-gradient(ellipse 820px 480px at 84% -12%, rgba(196,210,235,0.20), transparent 60%),
    /* 2. нижний левый насыщенный подсвет (объём снизу) */
    radial-gradient(ellipse 760px 420px at 6% 116%, rgba(96,112,140,0.30), transparent 56%),
    /* 3. верхний левый второй блик (перекрёстный свет) */
    radial-gradient(ellipse 560px 320px at 14% -8%, rgba(150,165,190,0.16), transparent 60%),
    /* 4. центральная подушка света под заголовком */
    radial-gradient(ellipse 680px 300px at 44% 36%, rgba(200,210,228,0.10), transparent 70%),
    /* 5. нижний правый тёплый отблеск (контраст холод/тепло) */
    radial-gradient(ellipse 520px 320px at 96% 104%, rgba(70,58,52,0.40), transparent 58%),
    /* 6. виньетка по краям (затемнение, фокус в центре) */
    radial-gradient(ellipse 130% 95% at 50% 42%, transparent 48%, rgba(0,0,0,0.42) 100%),
    /* 7. диагональный блик-световота сверху-слева → снизу-справа */
    linear-gradient(125deg, rgba(255,255,255,0.06) 0%, transparent 26%, transparent 70%, rgba(0,0,0,0.30) 100%),
    /* 8. горизонтальный «горизонт» — мягкая световая полоса */
    linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 22%, transparent 64%, rgba(0,0,0,0.20) 100%),
    /* 9. тонкая сетка-черновик (road/blueprint feel) */
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.05) 1px, transparent 0),
    /* 10. основной серый градиент с переходом тонов */
    linear-gradient(120deg, #121519 0%, #23272f 44%, #353c47 76%, #2a2f38 100%);
  background-size:
    100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%,
    100% 100%, 100% 100%, 22px 22px, 100% 100%;
  background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, repeat, no-repeat;
  border-top: 1px solid rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(0,0,0,0.45);
  box-shadow:
    inset 0 22px 50px -22px rgba(0,0,0,0.55),
    inset 0 -48px 70px -34px rgba(0,0,0,0.55),
    inset 0 0 0 1px rgba(255,255,255,0.03);
}
/* Дополнительная мягкая «полоса света» по центру — отдельно, чтобы не мешать фону */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 40%, rgba(255,255,255,0.045) 50%, transparent 60%);
  opacity: 0.7;
}
.hero > .container { position: relative; z-index: 3; }
.hero-road { z-index: 2; }

.hero h1 {
  font-size: 38px; margin: 0 0 10px; font-weight: 800;
  background: linear-gradient(180deg, #ffffff 0%, #cdd4df 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: #fff;
  text-shadow: 0 2px 18px rgba(0,0,0,0.5);
  letter-spacing: -0.01em;
}
.hero p { font-size: 18px; opacity: .94; margin: 0 0 24px; max-width: 620px; text-shadow: 0 1px 10px rgba(0,0,0,0.5); }
.hero .btn { background: #fff; color: #20242c; box-shadow: 0 8px 22px rgba(0,0,0,0.34); }
.hero .btn:hover { background: #eef1f6; transform: translateY(-1px); box-shadow: 0 10px 26px rgba(0,0,0,0.4); }

/* car body — simple SVG-ish via CSS shapes */
.car-body {
  width: 52px;
  height: 22px;
  background: #ffca28;
  border-radius: 4px 12px 2px 2px;
  position: relative;
}
.car-window {
  width: 20px;
  height: 14px;
  background: rgba(255,255,255,.5);
  border-radius: 3px 8px 0 0;
  position: absolute;
  top: -14px;
  right: 2px;
}
#wheel-f, #wheel-r {
  width: 9px;
  height: 9px;
  background: #1a1a2e;
  border-radius: 50%;
  position: absolute;
  bottom: -4px;
  border: 1px solid #333;
  animation: wheel-spin .3s linear infinite;
}
#wheel-f { right: 4px; }
#wheel-r { left: 6px; }
@keyframes wheel-spin {
  to { transform: rotate(360deg); }
}

/* ---------- SECTION ---------- */
section { padding: 36px 0; }
.section-title { font-size: 24px; font-weight: 700; margin: 0 0 20px; }

/* ---------- FILTERS ---------- */
.filters {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 24px; box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}

/* ---------- GRID OF TRAILERS ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
}
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card .thumb { height: 180px; background: #e0e6ee center/cover no-repeat; position: relative; }
.card .thumb .tag { position: absolute; top: 10px; left: 10px; }
.card .body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.card .type { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.card .specs { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin: 8px 0; flex-wrap: wrap; }
.card .specs b { color: var(--text); font-weight: 600; }
.card .price { font-size: 18px; font-weight: 700; margin: 8px 0 12px; }
.card .price small { font-size: 12px; color: var(--muted); font-weight: 400; }
.card .actions { margin-top: auto; display: flex; gap: 8px; }
.card .nextfree { font-size: 12px; color: var(--amber); margin-top: 6px; }

/* ---------- BADGE ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.badge-free      { background: #d1fae5; color: #065f46; }
.badge-busy      { background: #fee2e2; color: #991b1b; }
.badge-reserved  { background: #fef3c7; color: #92400e; }
.badge-stop      { background: #f3e8ff; color: #6b21a8; }

/* ---------- AVAILABILITY TABLE ---------- */
.avail-table { overflow-x: auto; }
.avail-table table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.avail-table th, .avail-table td { padding: 10px 8px; text-align: center; font-size: 12px; border: 1px solid var(--border); }
.avail-table th { background: #f0f4ff; font-weight: 700; }
.avail-table td.free { background: #ecfdf5; }
.avail-table td.busy { background: #fef2f2; }
.avail-table td.reserved { background: #fffbeb; }
.avail-table td.stop { background: #faf5ff; }
.avail-table td.today { outline: 2px solid var(--primary); }

/* ---------- AUTH / FORMS ---------- */
.auth-wrap { max-width: 420px; margin: 40px auto; }
.form-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.form-card h1 { margin: 0 0 6px; font-size: 24px; }
.form-card .sub { color: var(--muted); margin-bottom: 22px; }
.form-card .field { margin-bottom: 14px; }
.form-card .btn { width: 100%; margin-top: 6px; }
.form-card .alt { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ---------- TRAILER PAGE ---------- */
.trailer-detail { display: grid; grid-template-columns: 1.2fr 1fr; gap: 30px; }
@media (max-width: 800px) { .trailer-detail { grid-template-columns: 1fr; } }
.trailer-photo { width: 100%; height: 380px; object-fit: cover; border-radius: var(--radius); }
.detail-spec { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; margin: 16px 0; }
.detail-spec div { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.detail-spec b { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.booking-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  position: sticky; top: 90px;
}
.booking-box h3 { margin: 0 0 14px; }
.total-row { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; padding: 14px 0 0; border-top: 1px solid var(--border); margin-top: 10px; }

/* ---------- PROFILE ---------- */
.bookings-list { display: flex; flex-direction: column; gap: 14px; }
.booking-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; box-shadow: var(--shadow);
}
.booking-item .info { flex: 1; min-width: 200px; }
.booking-item .info h4 { margin: 0 0 4px; }
.booking-item .info .meta { color: var(--muted); font-size: 13px; }

/* ---------- ADMIN ---------- */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
@media (max-width: 800px) { .admin-layout { grid-template-columns: 1fr; } }
.admin-side {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; height: fit-content; box-shadow: var(--shadow);
}
.admin-side button {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  background: transparent; border: none; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 14px; color: var(--text); margin-bottom: 2px;
}
.admin-side button:hover { background: #f0f4ff; }
.admin-side button.active { background: var(--primary); color: #fff; }
.admin-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: linear-gradient(135deg,#f0f4ff,#fff); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 24px; font-weight: 800; margin-top: 4px; }

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
table.data th { background: #f8fafc; font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: 12px; }
table.data tr:hover { background: #f8fafc; }

/* ---------- TOASTS ---------- */
#toast-host { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1a2233; color: #fff; padding: 12px 18px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: 0; transform: translateX(40px);
  transition: all .3s; max-width: 320px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: var(--primary); }

/* ---------- FOOTER ---------- */
footer { background: #0f172a; color: #94a3b8; padding: 30px 0; margin-top: 60px; }
footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

/* ---------- MODAL ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal-bg.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); padding: 24px;
  max-width: 560px; width: 100%; max-height: 90vh; overflow: auto;
}
.modal h2 { margin: 0 0 16px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- PWA ADD-TO-HOMESCREEN MODAL ---------- */
.pwa-modal { text-align: center; }
.pwa-icon { font-size: 44px; margin-bottom: 4px; }
.pwa-steps {
  list-style: none; padding: 0; margin: 0 auto;
  text-align: left; max-width: 440px;
  display: flex; flex-direction: column; gap: 12px;
}
.pwa-steps li { display: flex; align-items: flex-start; gap: 10px; }
.pwa-step-num {
  flex: 0 0 26px; width: 26px; height: 26px;
  background: var(--primary); color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

/* ---------- MISC ---------- */
.muted { color: var(--muted); }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- FAQ ---------- */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--card);
}
.faq-q {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  color: var(--text);
}
.faq-q:hover { background: #f0f4ff; }
.faq-icon {
  font-size: 22px;
  font-weight: 400;
  color: var(--primary);
  flex-shrink: 0;
  line-height: 1;
}
.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease, padding .25s ease;
  padding: 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}
.faq-item.open .faq-a {
  max-height: 300px;
  padding: 0 18px 16px;
}

/* Постраничная навигация таблиц админки */
.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* ---------- HERO ANIMATION: Лада Гранта + прицеп ---------- */
.hero-road {
  position: relative;
  width: 100%;
  height: 90px;
  margin-top: 28px;
  overflow: hidden;
  border-top: 1px solid rgba(255,255,255,.18);
  background:
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(255,255,255,.35) 38px 58px);
  background-position: 0 78px;
  background-size: 60px 8px;
  background-repeat: repeat-x;
  background-color: transparent;
}
.hero-road::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: rgba(255,255,255,.45);
}
.hero-convoy {
  position: absolute;
  left: 0;
  bottom: 14px;
  display: flex;
  align-items: flex-end;
  gap: 0;
  transform: translateX(-340px);
  animation: convoy-drive 10s linear infinite;
  will-change: transform;
}
.hero-car, .hero-trailer {
  display: block;
}
.hero-car { 
  width: 200px; 
  height: auto; 
  transform: scaleX(-1);
  position: relative;
  z-index: 1;
}
.hero-trailer {
   width: 210px; height: auto;
   margin-right: -2px;
   transform: translateX(-260px) scaleX(1);
   transform-origin: center bottom;
   opacity: 0;
    animation: trailer-attach 10s linear infinite, trailer-sway 6s ease-in-out infinite alternate;
   position: relative;
   z-index: 2;
}
.hero-wheel-spin { transform-box: fill-box; transform-origin: center; will-change: transform; }
.hero-convoy .hero-wheel-spin {
  animation: wheel-roll .4s linear infinite;
}

/* Когда шапка ушла с экрана — ставим её анимацию на паузу (класс вешает JS),
   чтобы скролл остальной страницы не дёргался из-за перерисовки невидимого конвоя. */
.hero.paused .hero-convoy,
.hero.paused .hero-trailer,
.hero.paused .hero-wheel-spin { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .hero-convoy, .hero-trailer, .hero-convoy .hero-wheel-spin { animation: none !important; }
}

@keyframes wheel-roll { to { transform: rotate(360deg); } }

/*overall journey: въезд -> остановка в центре -> прицеп -> отъезд вправо*/
@keyframes convoy-drive {
  0%   { transform: translateX(-430px); }
  35%  { transform: translateX(calc(50vw - 215px)); }  /* конвой в центре экрана */
  55%  { transform: translateX(calc(50vw - 215px)); } /* стоит, цепляют прицеп */
  100% { transform: translateX(100vw); }              /* уехали вправо */
}

/* Прицеп появляется слева от машины и крепится к ней */
@keyframes trailer-attach {
  0%, 34%  { opacity: 0; transform: translateX(-260px) scaleX(1); }
  40%      { opacity: 1; transform: translateX(0) scaleX(1); }
  55%      { opacity: 1; transform: translateX(0) scaleX(1); }
  100%     { opacity: 1; transform: translateX(0) scaleX(1); }
}

@keyframes trailer-sway {
  0%   { transform: rotate(0deg); }
  50%  { transform: rotate(2deg); }
  100% { transform: rotate(-2deg); }
}

  /* Disabled animation rule removed to allow hero convoy animations */
/* end of reduced motion block */
