/* PimPin Prototype — Design System
   Modern, minimalistic, single-accent. */

:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-muted: #f5f5f5;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --text: #0a0a0a;
  --text-secondary: #525252;
  --text-muted: #737373;
  --accent: #0f766e;
  --accent-hover: #0c5e57;
  --accent-soft: #f0fdfa;
  --accent-text: #ffffff;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

h1, h2, h3, h4 { font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 24px; line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.4; }
h4 { font-size: 14px; line-height: 1.4; }

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 16px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: var(--bg);
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
}
.sidebar-brand {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}
.sidebar-brand-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 6px;
  display: grid; place-items: center;
}
.sidebar-tenant {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  font-size: 13px;
}
.sidebar-tenant:hover { background: var(--bg-subtle); }
.sidebar-tenant-mark {
  width: 28px; height: 28px;
  background: var(--bg-muted);
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
}
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-section { margin-bottom: 4px; }
.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 12px 12px 6px;
  font-weight: 600;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.sidebar-link:hover { background: var(--bg-subtle); color: var(--text); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-link.active svg { color: var(--accent); }
.sidebar-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.sidebar-footer-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-muted);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-secondary);
}
.sidebar-footer-name { font-weight: 500; }
.sidebar-footer-role { color: var(--text-muted); font-size: 11px; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-weight: 600; font-size: 16px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.page { padding: 24px; max-width: 1280px; width: 100%; }
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.page-header-text h1 { margin-bottom: 4px; }
.page-header-text .text-muted { font-size: 13px; }
.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-subtle); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #991b1b; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }
.btn-icon { padding: 8px; }
.btn-icon svg { width: 16px; height: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.card-header h3 { font-size: 15px; }
.card-body { padding: 20px; }
.card-body-flush { padding: 0; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { padding: 20px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; margin-bottom: 6px; }
.stat-trend { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-trend svg { width: 12px; height: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 10px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-subtle); }
.table tbody tr.clickable { cursor: pointer; }
.table-empty { padding: 48px 24px; text-align: center; color: var(--text-muted); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-dot::before {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor; margin-right: 4px;
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-help { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 6px; }
.form-row { display: flex; gap: 8px; align-items: flex-end; }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 10, 10, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
  animation: fade-in 0.15s;
}
.modal {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: scale-in 0.15s;
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1024px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; }
.modal-close { color: var(--text-muted); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg-subtle); border-radius: 0 0 var(--radius) var(--radius); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Filters bar */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 16px;
}
.search-input { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-input svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-muted);
}
.search-input input {
  width: 100%; padding: 8px 12px 8px 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.search-input input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Empty states */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}
.empty-state svg {
  width: 40px; height: 40px;
  color: var(--text-muted);
  margin: 0 auto 12px;
  display: block;
  stroke-width: 1.25;
}
.empty-state h3 { font-size: 15px; margin-bottom: 4px; }
.empty-state p { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }

/* Auth pages */
.auth-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background: var(--bg-subtle);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-md);
}
.auth-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 24px;
  font-weight: 600;
  font-size: 16px;
}

/* Calendar */
.cal-grid { display: grid; grid-template-columns: 180px repeat(14, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 12px; }
.cal-cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px 8px; min-height: 44px; }
.cal-cell:last-child { border-right: none; }
.cal-row:last-child .cal-cell { border-bottom: none; }
.cal-header { background: var(--bg-subtle); font-weight: 600; font-size: 11px; color: var(--text-muted); text-align: center; }
.cal-bike { background: var(--bg); display: flex; flex-direction: column; gap: 2px; }
.cal-bike-name { font-weight: 500; font-size: 12px; }
.cal-bike-meta { font-size: 11px; color: var(--text-muted); }
.cal-day { position: relative; cursor: pointer; }
.cal-day:hover { background: var(--bg-subtle); }
.cal-day.today { background: var(--accent-soft); }
.cal-booking { position: absolute; left: 2px; right: 2px; top: 4px; bottom: 4px; background: var(--accent); color: white; border-radius: 4px; padding: 2px 6px; font-size: 11px; font-weight: 500; display: flex; align-items: center; overflow: hidden; }
.cal-booking.maintenance { background: var(--warning); }
.cal-booking.confirmed { background: var(--accent); }
.cal-booking.checkedout { background: var(--success); }

/* Booking states */
.state-reserved { color: var(--accent); }
.state-checkedout { color: var(--success); }
.state-returned { color: var(--text-secondary); }
.state-cancelled { color: var(--danger); }
.state-noshow { color: var(--warning); }

/* Photo grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photo-tile {
  aspect-ratio: 1;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: grid; place-items: center;
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile.placeholder svg { width: 28px; height: 28px; }

/* Toggle */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle-track { width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: transform 0.15s; box-shadow: var(--shadow-sm); }
.toggle.on .toggle-track { background: var(--accent); }
.toggle.on .toggle-thumb { transform: translateX(16px); }

/* Avatar */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-muted);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }

/* Utility */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.divide-y > * + * { border-top: 1px solid var(--border); }
.hidden { display: none !important; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-main-side { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-main-side { grid-template-columns: 1fr; }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar-mobile-toggle { display: inline-flex; }
  .page { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 769px) {
  .topbar-mobile-toggle { display: none; }
}

.topbar-mobile-toggle {
  background: none; border: none; padding: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}

/* Charts (CSS-only bar chart) */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 12px 0; }
.bar-chart-bar { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 4px; position: relative; transition: opacity 0.15s; }
.bar-chart-bar:hover { opacity: 0.85; }
.bar-chart-bar.muted { background: var(--border-strong); }
.bar-chart-labels { display: flex; gap: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.bar-chart-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--text-muted); }

/* Tenant impersonation banner */
.impersonation-banner {
  background: var(--warning);
  color: white;
  padding: 8px 16px;
  font-size: 12px;
  text-align: center;
  font-weight: 500;
}
.impersonation-banner a { text-decoration: underline; }

/* Lists */
.list { list-style: none; }
.list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.list-item:last-child { border-bottom: none; }
.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-weight: 500; font-size: 13px; }
.list-item-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Public/rider pages */
.public-shell { max-width: 720px; margin: 0 auto; padding: 24px; }
.public-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow-sm); }
.public-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px; }
.public-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.lang-switcher select { font-size: 12px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); }

/* Hero info row */
.info-row { display: flex; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row-label { width: 160px; color: var(--text-muted); flex-shrink: 0; }
.info-row-value { flex: 1; font-weight: 500; }

/* Loading skeletons (used during seeding) */
.skeleton { background: linear-gradient(90deg, var(--bg-muted) 0%, var(--bg-subtle) 50%, var(--bg-muted) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-track { background: transparent; }
