/* ============================================================
   CAR Parking — Design System
   ============================================================ */

:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #dbeafe;
  --accent: #10b981;
  --accent-dark: #059669;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --bg-grad-1: #eef2ff;
  --bg-grad-2: #ecfeff;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12);
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
}

* { -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.bg-grad {
  background:
    radial-gradient(circle at 0% 0%, var(--bg-grad-1) 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, var(--bg-grad-2) 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -0.01em; }
.text-muted { color: var(--muted) !important; }
.text-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* ---------- Brand / Nav ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-sm);
}
.topnav {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topnav .container { padding-top: 12px; padding-bottom: 12px; }

/* ---------- Cards ---------- */
.cp-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px;
}
.cp-card-tight { padding: 16px; border-radius: var(--radius); }
.cp-card-hero {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  border: 1px solid var(--border);
}

/* ---------- Buttons ---------- */
.btn {
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
  padding: 10px 18px;
  border: none;
  transition: all .18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: translateY(1px) scale(0.98); }

.btn-brand {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}
.btn-brand:hover { filter: brightness(1.08); color: white; }

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}
.btn-accent:hover { filter: brightness(1.08); color: white; }

.btn-danger-solid {
  background: var(--danger);
  color: white;
}
.btn-danger-solid:hover { background: var(--danger-dark); color: white; }

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

.btn-lg {
  padding: 16px 24px;
  font-size: 16px;
  border-radius: 14px;
}

.btn-xl {
  padding: 20px 24px;
  font-size: 17px;
  border-radius: 18px;
  width: 100%;
}

.btn i { font-size: 1.1em; }

/* ---------- Inputs ---------- */
.form-control, .form-select {
  border-radius: 12px;
  border: 1.5px solid var(--border);
  padding: 12px 14px;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.form-label { font-weight: 600; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* ---------- Plate badge ---------- */
.plate {
  display: inline-block;
  background: #facc15;
  color: #0f172a;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 800;
  font-size: 22px;
  padding: 10px 18px;
  border-radius: 10px;
  letter-spacing: 0.04em;
  border: 3px solid #0f172a;
  box-shadow: 0 2px 0 #0f172a;
}
.plate-lg { font-size: 28px; padding: 14px 24px; }

/* ---------- Sidebar layout ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  padding: 20px;
  max-width: 1280px;
  margin: 0 auto;
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; padding: 12px; }
}

.sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: 80px;
}
@media (max-width: 860px) { .sidebar { position: static; } }

.sidebar-section { margin-bottom: 18px; }
.sidebar-title {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted-light);
  margin-bottom: 8px;
  padding: 0 6px;
}

.s-item {
  display: block;
  padding: 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 4px;
  cursor: pointer;
  transition: background .12s;
  border: 1px solid transparent;
}
.s-item:hover { background: var(--bg); color: var(--text); }
.s-item.active {
  background: var(--brand-light);
  border-color: #bfdbfe;
}
.s-item .s-title { font-weight: 600; font-size: 14px; }
.s-item .s-sub { font-size: 12px; color: var(--muted); }

.unread-dot {
  display: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-left: 6px;
  vertical-align: middle;
}
.unread-dot.show { display: inline-block; }

/* ---------- Chat bubbles ---------- */
.chat-area {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: white;
}
.chat-header-info { display: flex; flex-direction: column; gap: 2px; }
.chat-header-info .plate { font-size: 14px; padding: 4px 10px; border-width: 2px; box-shadow: 0 1px 0 #0f172a; }

.chat-log {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 360px;
  max-height: 52vh;
}
.chat-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}
.chat-bubble.me {
  align-self: flex-end;
  background: var(--brand);
  color: white;
  border-bottom-right-radius: 6px;
}
.chat-bubble.them {
  align-self: flex-start;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.chat-time {
  font-size: 10.5px;
  color: var(--muted-light);
  margin-top: 2px;
  padding: 0 10px;
}
.chat-time.me { align-self: flex-end; }
.chat-time.them { align-self: flex-start; }

.chat-input-row {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  background: white;
}

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--muted);
  padding: 40px 20px;
  text-align: center;
}
.chat-empty i { font-size: 48px; color: var(--muted-light); margin-bottom: 12px; }

/* ---------- Public contact page ---------- */
.public-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.public-card {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 28px 28px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.public-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.public-hero-icon {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--brand-light), #e0e7ff);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--brand);
}

.privacy-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
}
.privacy-note i { color: var(--accent); font-size: 14px; margin-top: 1px; }

/* ---------- Incoming call banner ---------- */
.incoming-call {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 18px 20px;
  min-width: 320px;
  max-width: 92vw;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 2px solid var(--accent);
  animation: slideDown .4s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -30px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.incoming-call .pulse-ring {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  position: relative;
  flex-shrink: 0;
}
.incoming-call .pulse-ring::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  animation: pulseRing 1.4s ease-out infinite;
}
@keyframes pulseRing {
  0%   { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
.incoming-call .ic-info { flex: 1; min-width: 0; }
.incoming-call .ic-info .ic-title { font-weight: 700; font-size: 15px; }
.incoming-call .ic-info .ic-sub { font-size: 12px; color: var(--muted); }
.incoming-call .ic-actions { display: flex; gap: 8px; flex-shrink: 0; }
.ic-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  color: white;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.ic-btn.accept { background: var(--accent); }
.ic-btn.decline { background: var(--danger); }

/* ---------- Full-screen call overlay ---------- */
.call-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 48px 24px 40px;
  color: white;
}
.call-overlay.hidden { display: none; }
.call-avatar {
  width: 160px; height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, #334155, #475569);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  color: rgba(255,255,255,0.8);
  margin: 40px 0 28px;
  position: relative;
}
.call-avatar.ringing::before,
.call-avatar.ringing::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 3px solid rgba(16, 185, 129, 0.7);
  animation: callPulse 1.6s ease-out infinite;
}
.call-avatar.ringing::after { animation-delay: 0.8s; }
@keyframes callPulse {
  0%   { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
.call-top {
  text-align: center;
  margin-top: 20px;
}
.call-top .call-status {
  font-size: 15px;
  opacity: 0.8;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.call-top .call-who {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}
.call-top .call-plate {
  font-size: 14px;
  opacity: 0.7;
}
.call-timer { font-size: 18px; opacity: 0.9; font-variant-numeric: tabular-nums; margin-top: 8px; }

.call-controls {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  margin-top: auto;
}
.call-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: none;
  color: white;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .1s, background .15s;
  backdrop-filter: blur(10px);
}
.call-btn:active { transform: scale(0.92); }
.call-btn.mute { background: rgba(255, 255, 255, 0.15); }
.call-btn.mute.active { background: rgba(255, 255, 255, 0.9); color: #0f172a; }
.call-btn.hangup {
  background: var(--danger);
  width: 72px; height: 72px;
  font-size: 28px;
}

/* ---------- QR display ---------- */
.qr-wrap {
  display: inline-block;
  padding: 16px;
  background: white;
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.qr-wrap img { display: block; max-width: 260px; width: 100%; }

/* ---------- Status indicators ---------- */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted-light);
  margin-right: 6px;
}
.status-dot.online { background: var(--accent); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }
.status-dot.offline { background: var(--muted-light); }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cp-toast {
  background: white;
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 14px;
  min-width: 240px;
  max-width: 320px;
  animation: slideIn .3s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Badges ---------- */
.cp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cp-badge.active { background: #dcfce7; color: #15803d; }
.cp-badge.inactive { background: #fef3c7; color: #92400e; }

/* ---------- Alerts ---------- */
.cp-alert {
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid;
}
.cp-alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.cp-alert.danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.cp-alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ---------- Utility ---------- */
.stack-v { display: flex; flex-direction: column; }
.stack-h { display: flex; flex-direction: row; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }

hr.soft { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
