/* Design system for the trailer rental app.
 *
 * Loaded unconditionally. Tailwind utilities (compiled bundle or Play CDN)
 * handle layout; everything with a name here is a stable component the
 * templates rely on, so the UI keeps its look even without the CSS build.
 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --brand: #1d4ed8;
  --brand-weak: #eff4ff;
  --success: #067647;
  --success-weak: #ecfdf3;
  --info: #175cd3;
  --info-weak: #eff8ff;
  --warn: #b54708;
  --warn-weak: #fffaeb;
  --danger: #b42318;
  --danger-weak: #fef3f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

[x-cloak] { display: none !important; }

/* ── shell ─────────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  display: none;
  width: 248px;
  flex: 0 0 248px;
  padding: 22px 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand-text { font-weight: 650; line-height: 1.15; }
.brand-text small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }

.nav-list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px;
  color: #344054; font-weight: 500;
}
.nav-link:hover { background: #f2f4f7; text-decoration: none; }
.nav-link.is-active { background: var(--brand-weak); color: var(--brand); font-weight: 600; }
.nav-link svg { width: 18px; height: 18px; flex: none; }

.sidebar-footer { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px);
}
.topbar h1 { font-size: 1.15rem; }
.topbar-meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }

.content { padding: 16px 16px 88px; width: 100%; max-width: 1240px; margin: 0 auto; }

.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--panel); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; font-size: 11px; color: var(--muted); border-radius: 10px;
}
.bottom-nav a svg { width: 20px; height: 20px; }
.bottom-nav a.is-active { color: var(--brand); background: var(--brand-weak); }
.bottom-nav a:hover { text-decoration: none; }

@media (min-width: 1024px) {
  .sidebar { display: flex; flex-direction: column; }
  .content { padding: 24px 28px 64px; }
  .bottom-nav { display: none; }
  .topbar { padding: 16px 28px; }
}

/* ── surfaces ──────────────────────────────────────────────────────────── */

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.card-header h2 { font-size: 1rem; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card + .card { margin-top: 16px; }

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-two { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-two { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}

.stat { padding: 14px 16px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-value.small { font-size: 1.15rem; }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-value.is-success { color: var(--success); }
.stat-value.is-danger { color: var(--danger); }
.stat-value.is-warn { color: var(--warn); }

/* ── controls ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: #344054;
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #1a43c0; }
.btn-danger { background: var(--danger-weak); border-color: #fecdca; color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 550; color: #344054; }
.field-input {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid #d0d5dd; border-radius: 10px; background: #fff;
  font: inherit; color: var(--text);
}
.field-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12); }
.field-input.is-invalid { border-color: #f04438; }
textarea.field-input { min-height: 72px; resize: vertical; }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--danger); }
.field-row { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .field-row.two { grid-template-columns: 1fr 1fr; } }

.field-checkbox { width: 18px; height: 18px; accent-color: var(--brand); }

/* ── badges, tabs, tables ──────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #f2f4f7; color: #344054; white-space: nowrap;
}
.badge-success { background: var(--success-weak); color: var(--success); }
.badge-info { background: var(--info-weak); color: var(--info); }
.badge-warn { background: var(--warn-weak); color: var(--warn); }
.badge-danger { background: var(--danger-weak); color: var(--danger); }
.badge-muted { background: #f2f4f7; color: #475467; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px; background: #f2f4f7; border-radius: 12px; }
.tab {
  padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 550;
  color: #475467; white-space: nowrap;
}
.tab:hover { background: #fff; text-decoration: none; }
.tab.is-active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); font-weight: 600; padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: #fcfcfd;
}
.table td { padding: 12px; border-bottom: 1px solid #f2f4f7; vertical-align: middle; }
.table tbody tr:hover { background: #fcfcfd; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table a.row-link { font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.spacer { flex: 1; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ── messages & dialogs ────────────────────────────────────────────────── */

.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.message { padding: 10px 14px; border-radius: 10px; font-size: 14px; border: 1px solid transparent; }
.message.success { background: var(--success-weak); color: var(--success); border-color: #abefc6; }
.message.error { background: var(--danger-weak); color: var(--danger); border-color: #fecdca; }
.message.warning { background: var(--warn-weak); color: var(--warn); border-color: #fedf89; }
.message.info { background: var(--info-weak); color: var(--info); border-color: #b2ddff; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: rgba(16, 24, 40, 0.45);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  width: min(560px, 100%); max-height: 90vh; overflow: auto;
  background: var(--panel); border-radius: 16px; box-shadow: 0 20px 40px rgba(16, 24, 40, 0.2);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px; }

/* ── rental calc & calendar ────────────────────────────────────────────── */

.calc-card { background: var(--brand-weak); border: 1px solid #d1e0ff; border-radius: var(--radius); padding: 14px 16px; }
.calc-total { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.calc-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: #344054; }
.calc-conflict { background: var(--danger-weak); border-color: #fecdca; color: var(--danger); }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-head { font-size: 11px; text-transform: uppercase; color: var(--muted); text-align: center; padding: 4px 0; }
.calendar-day {
  aspect-ratio: 1 / 1; display: grid; place-items: center; border-radius: 8px;
  font-size: 13px; background: #fff; border: 1px solid #f2f4f7;
}
.calendar-day.is-outside { color: #98a2b3; background: transparent; border-color: transparent; }
.calendar-day.is-busy { background: #fee4e2; color: var(--danger); border-color: #fecdca; font-weight: 600; }
.calendar-day.is-today { outline: 2px solid var(--brand); }
.calendar-day.is-selected { background: var(--brand); color: #fff; }

/* ── chart ─────────────────────────────────────────────────────────────── */

.chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 8px; }
.chart-bar { flex: 1; min-width: 4px; background: #b2ccff; border-radius: 4px 4px 0 0; position: relative; }
.chart-bar:hover { background: var(--brand); }
.chart-bar span { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); }
.chart-caption { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 26px; }

/* ── auth ──────────────────────────────────────────────────────────────── */

.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }

/* Mobile list cards */
.rental-cards { display: grid; gap: 10px; }
.rental-card { padding: 14px; display: grid; gap: 8px; }
.rental-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.rental-card-title { font-weight: 650; }
.rental-card-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.rental-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

@media (max-width: 767px) {
  .desktop-only { display: none !important; }
  .table-wrap.desktop-only { display: none; }
}
@media (min-width: 768px) {
  .mobile-only { display: none !important; }
}
