/* =====================================================
   GearRent — Design System
   Single source stylesheet. Component based. CSS variables.
   ===================================================== */

:root {
  /* Brand */
  --gr-primary: #2F6FED;
  --gr-primary-dark: #1E54C9;
  --gr-primary-light: #EAF1FF;

  /* Role accents */
  --gr-owner: #16A34A;
  --gr-owner-light: #E8F8EE;
  --gr-admin: #8B36E0;
  --gr-admin-light: #F3E9FE;
  --gr-developer: #F97316;
  --gr-developer-light: #FFF1E5;

  /* Status */
  --gr-success: #16A34A;
  --gr-success-light: #E8F8EE;
  --gr-warning: #F59E0B;
  --gr-warning-light: #FEF6E7;
  --gr-danger: #EF4444;
  --gr-danger-light: #FDECEC;
  --gr-info: #2F6FED;
  --gr-info-light: #EAF1FF;

  /* Neutrals */
  --gr-bg: #F5F7FB;
  --gr-surface: #FFFFFF;
  --gr-border: #E7EBF3;
  --gr-text: #1E2433;
  --gr-text-muted: #6B7280;
  --gr-text-faint: #9AA3B2;

  /* Elevation */
  --gr-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --gr-shadow-md: 0 6px 20px rgba(16, 24, 40, 0.06);
  --gr-shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.10);

  /* Radius */
  --gr-radius-sm: 8px;
  --gr-radius-md: 12px;
  --gr-radius-lg: 18px;
  --gr-radius-pill: 999px;

  /* Layout */
  --gr-sidebar-w: 260px;
  --gr-sidebar-w-collapsed: 84px;
  --gr-topbar-h: 72px;

  /* Type */
  --gr-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --gr-bg: #10131C;
  --gr-surface: #1A1E2B;
  --gr-border: #2B3040;
  --gr-text: #F2F4F8;
  --gr-text-muted: #A7AEBD;
  --gr-text-faint: #6B7280;
  --gr-primary-light: rgba(47, 111, 237, 0.16);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--gr-bg);
  color: var(--gr-text);
  font-family: var(--gr-font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

::selection { background: var(--gr-primary-light); }

.gr-container { max-width: 1320px; margin: 0 auto; padding: 0 24px; }

/* =====================================================
   Buttons
   ===================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--gr-radius-sm);
  padding: 11px 20px;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background-color .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--gr-primary-light); outline-offset: 2px; }

.btn-primary { background: var(--gr-primary); color: #fff; box-shadow: var(--gr-shadow-sm); }
.btn-primary:hover { background: var(--gr-primary-dark); text-decoration: none; }

.btn-outline { background: var(--gr-surface); color: var(--gr-text); border-color: var(--gr-border); }
.btn-outline:hover { border-color: var(--gr-text-faint); text-decoration: none; }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-icon { padding: 10px; border-radius: var(--gr-radius-sm); }

.btn-danger { background: var(--gr-danger); color: #fff; }
.btn-success { background: var(--gr-success); color: #fff; }

/* =====================================================
   Forms
   ===================================================== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 7px; color: var(--gr-text); }

.input-wrap { position: relative; }
.input-wrap .icon-left {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--gr-text-faint); font-size: 14px; pointer-events: none;
}
.input-wrap .icon-right {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--gr-text-faint); font-size: 14px; background: none; border: none; cursor: pointer; padding: 4px;
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gr-border);
  border-radius: var(--gr-radius-sm);
  background: var(--gr-surface);
  color: var(--gr-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus { outline: none; border-color: var(--gr-primary); box-shadow: 0 0 0 4px var(--gr-primary-light); }
.input-wrap .form-control.has-icon-left { padding-left: 40px; }
.input-wrap .form-control.has-icon-right { padding-right: 40px; }

.form-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--gr-text-muted); }
.form-check input { width: 16px; height: 16px; accent-color: var(--gr-primary); cursor: pointer; }

.form-hint { font-size: 12.5px; color: var(--gr-text-faint); margin-top: 6px; }
.form-error { font-size: 12.5px; color: var(--gr-danger); margin-top: 6px; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* =====================================================
   Alerts / Banners / Toasts
   ===================================================== */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: var(--gr-radius-sm); font-size: 13.5px; border: 1px solid transparent; }
.alert-info { background: var(--gr-info-light); color: var(--gr-primary-dark); border-color: rgba(47,111,237,.18); }
.alert-success { background: var(--gr-success-light); color: #0F7A38; border-color: rgba(22,163,74,.2); }
.alert-warning { background: var(--gr-warning-light); color: #92650B; border-color: rgba(245,158,11,.25); }
.alert-danger { background: var(--gr-danger-light); color: #B42318; border-color: rgba(239,68,68,.2); }

#toast-stack { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast-item { min-width: 260px; background: var(--gr-surface); border: 1px solid var(--gr-border); box-shadow: var(--gr-shadow-lg); border-radius: var(--gr-radius-sm); padding: 12px 16px; font-size: 13.5px; animation: gr-slide-in .2s ease; }
@keyframes gr-slide-in { from { opacity: 0; transform: translateX(16px);} to { opacity: 1; transform: translateX(0);} }

/* =====================================================
   Badges / Status pills
   ===================================================== */
.badge { display: inline-flex; align-items: center; padding: 4px 11px; border-radius: var(--gr-radius-pill); font-size: 12px; font-weight: 700; }
.badge-info { background: var(--gr-info-light); color: var(--gr-primary-dark); }
.badge-success { background: var(--gr-success-light); color: #0F7A38; }
.badge-warning { background: var(--gr-warning-light); color: #92650B; }
.badge-danger { background: var(--gr-danger-light); color: #B42318; }
.badge-muted { background: #F1F3F8; color: var(--gr-text-muted); }

/* =====================================================
   Cards
   ===================================================== */
.card {
  background: var(--gr-surface);
  border: 1px solid var(--gr-border);
  border-radius: var(--gr-radius-lg);
  box-shadow: var(--gr-shadow-md);
}
.card-body { padding: 22px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--gr-border); }
.card-header h3 { font-size: 16px; }

/* Stat card (dashboard top cards) */
.stat-card { display: flex; align-items: center; gap: 14px; padding: 20px; }
.stat-icon { width: 46px; height: 46px; min-width: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.stat-value { font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--gr-text-muted); margin-top: 3px; }

.stat-icon.tone-blue   { background: var(--gr-info-light); color: var(--gr-primary); }
.stat-icon.tone-green  { background: var(--gr-success-light); color: var(--gr-success); }
.stat-icon.tone-purple { background: var(--gr-admin-light); color: var(--gr-admin); }
.stat-icon.tone-orange { background: var(--gr-developer-light); color: var(--gr-developer); }
.stat-icon.tone-red    { background: var(--gr-danger-light); color: var(--gr-danger); }

/* =====================================================
   App shell: sidebar + topbar + content
   ===================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--gr-sidebar-w);
  background: var(--gr-surface);
  border-right: 1px solid var(--gr-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: width .18s ease;
  z-index: 40;
}
.sidebar.collapsed { width: var(--gr-sidebar-w-collapsed); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; }

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 22px 22px 18px; font-weight: 800; font-size: 19px; }
.sidebar-brand .brand-logo { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sidebar-brand .brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 14px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 3px;
  border-radius: var(--gr-radius-sm);
  color: var(--gr-text-muted); font-weight: 600; font-size: 14px;
  transition: background-color .15s ease, color .15s ease;
}
.nav-link i { width: 18px; text-align: center; font-size: 15px; }
.nav-link:hover { background: var(--gr-bg); color: var(--gr-text); text-decoration: none; }
.nav-link.active { background: var(--gr-primary-light); color: var(--gr-primary); }

/* Role-tinted active nav states */
.theme-owner .nav-link.active { background: var(--gr-owner-light); color: var(--gr-owner); }
.theme-admin .nav-link.active { background: var(--gr-admin-light); color: var(--gr-admin); }
.theme-developer .nav-link.active { background: var(--gr-developer-light); color: var(--gr-developer); }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--gr-border); }

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

.topbar {
  height: var(--gr-topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px;
  background: var(--gr-surface);
  border-bottom: 1px solid var(--gr-border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }

.icon-btn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--gr-border); background: var(--gr-surface); color: var(--gr-text-muted); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--gr-bg); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--gr-danger); border: 2px solid var(--gr-surface); }

.profile-menu { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 8px; border-radius: 12px; }
.profile-menu:hover { background: var(--gr-bg); }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--gr-primary-light); }
.profile-name { font-size: 14px; font-weight: 700; line-height: 1.2; }
.profile-role { font-size: 11.5px; color: var(--gr-text-muted); }

.content { padding: 26px; flex: 1; }
.page-title { font-size: 22px; margin-bottom: 4px; }
.page-subtitle { color: var(--gr-text-muted); font-size: 14px; margin-bottom: 24px; }

/* Grids */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  /* Browse/favorites equipment grids */
  [style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: repeat(2, 1fr) !important; }
  /* Filter bar on browse */
  [style*="grid-template-columns:2fr 1fr 1fr 1fr auto"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:2fr 1fr 1fr 1fr auto"] + div { margin-top: 12px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns:repeat(2,1fr)"] { grid-template-columns: 1fr !important; }
  /* Equipment form fields */
  [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1fr 1fr 1fr"] { grid-template-columns: 1fr !important; }
}

/* List rows inside cards (recent bookings etc) */
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--gr-border); }
.list-row:last-child { border-bottom: none; }
.list-thumb { width: 52px; height: 52px; border-radius: 10px; background: var(--gr-bg); object-fit: cover; }
.list-title { font-weight: 700; font-size: 14px; }
.list-meta { font-size: 12.5px; color: var(--gr-text-muted); margin-top: 2px; }
.list-row .list-info { flex: 1; min-width: 0; }

.quick-action { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; border: 1px solid var(--gr-border); border-radius: var(--gr-radius-sm); margin-bottom: 10px; color: var(--gr-text); font-weight: 600; font-size: 14px; transition: border-color .15s ease, background-color .15s; }
.quick-action:hover { border-color: var(--gr-primary); background: var(--gr-primary-light); text-decoration: none; }
.quick-action i.left-icon { margin-right: 10px; color: var(--gr-primary); }

/* =====================================================
   Auth pages (login / register)
   ===================================================== */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--gr-bg); }
.auth-topbar { display: flex; align-items: center; justify-content: space-between; padding: 22px 40px; }
.auth-body { flex: 1; display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 40px; align-items: center; max-width: 1280px; margin: 0 auto; padding: 20px 40px 40px; width: 100%; }
.auth-hero h1 { font-size: 34px; line-height: 1.15; margin-bottom: 12px; }
.auth-hero h1 .accent { color: var(--gr-primary); }
.auth-hero p { color: var(--gr-text-muted); font-size: 15px; margin-bottom: 26px; max-width: 440px; }

.feature-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.feature-icon { width: 42px; height: 42px; min-width: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.feature-row h4 { font-size: 14.5px; margin-bottom: 3px; }
.feature-row p { font-size: 13px; color: var(--gr-text-muted); margin: 0; }

.auth-card { background: var(--gr-surface); border: 1px solid var(--gr-border); border-radius: var(--gr-radius-lg); box-shadow: var(--gr-shadow-lg); padding: 32px; }
.auth-card h2 { font-size: 21px; margin-bottom: 6px; }
.auth-card .subtitle { color: var(--gr-text-muted); font-size: 13.5px; margin-bottom: 22px; }

.auth-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--gr-border); margin-bottom: 22px; }
.auth-tab { padding-bottom: 12px; font-weight: 700; font-size: 14px; color: var(--gr-text-muted); border-bottom: 2px solid transparent; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.auth-tab.active { color: var(--gr-primary); border-color: var(--gr-primary); }
.auth-tab .new-pill { background: var(--gr-success-light); color: #0F7A38; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: var(--gr-radius-pill); }

.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--gr-text-faint); font-size: 12.5px; margin: 20px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--gr-border); }

.social-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px; border: 1.5px solid var(--gr-border); border-radius: var(--gr-radius-sm); background: var(--gr-surface); font-weight: 600; font-size: 14px; color: var(--gr-text); cursor: pointer; margin-bottom: 10px; }
.social-btn:hover { background: var(--gr-bg); text-decoration: none; }

.auth-footer { text-align: center; padding: 20px; font-size: 13px; color: var(--gr-text-muted); display: flex; justify-content: space-between; max-width: 1280px; margin: 0 auto; width: 100%; padding: 22px 40px; }
.auth-footer nav a { color: var(--gr-text-muted); margin-left: 18px; }

.notice-box { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--gr-info-light); border-radius: var(--gr-radius-sm); font-size: 12.5px; color: var(--gr-primary-dark); margin-bottom: 18px; }
.notice-box.success { background: var(--gr-success-light); color: #0F7A38; }

.role-hint-card { background: var(--gr-surface); border: 1px solid var(--gr-border); border-radius: var(--gr-radius-md); padding: 16px; margin-top: 18px; }

@media (max-width: 980px) {
  .auth-body { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

/* =====================================================
   Tables
   ===================================================== */
.table-wrap { overflow-x: auto; }
table.gr-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.gr-table th { text-align: left; padding: 12px 14px; color: var(--gr-text-muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--gr-border); }
table.gr-table td { padding: 14px; border-bottom: 1px solid var(--gr-border); vertical-align: middle; }
table.gr-table tr:last-child td { border-bottom: none; }
table.gr-table tr:hover td { background: var(--gr-bg); }

/* =====================================================
   Modal
   ===================================================== */
.gr-modal-backdrop { position: fixed; inset: 0; background: rgba(16,19,28,.5); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.gr-modal-backdrop.open { display: flex; }
.gr-modal { background: var(--gr-surface); border-radius: var(--gr-radius-lg); width: 100%; max-width: 480px; box-shadow: var(--gr-shadow-lg); animation: gr-pop .16s ease; }
@keyframes gr-pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.gr-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--gr-border); }
.gr-modal-body { padding: 20px; }
.gr-modal-footer { padding: 16px 20px; border-top: 1px solid var(--gr-border); display: flex; justify-content: flex-end; gap: 10px; }

/* =====================================================
   Utilities
   ===================================================== */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-0{margin-top:0} .mb-0{margin-bottom:0}
.text-muted { color: var(--gr-text-muted); }
.text-center { text-align: center; }
.w-100 { width: 100%; }
.mobile-only { display: none; }
.desktop-only { display: flex; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -100%; top: 0; height: 100vh; box-shadow: var(--gr-shadow-lg); }
  .sidebar.mobile-open { left: 0; }
  .mobile-only { display: flex; }
  .desktop-only { display: none !important; }
}

/* =====================================================
   Bottom nav (mobile)
   ===================================================== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 64px; background: var(--gr-surface);
  border-top: 1px solid var(--gr-border);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 40; padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; flex: 1; height: 100%; color: var(--gr-text-muted);
  font-size: 11px; font-weight: 600; text-decoration: none;
}
.bottom-nav-link i { font-size: 18px; }
.bottom-nav-link.active { color: var(--gr-primary); }
.bottom-nav-link:hover { text-decoration: none; color: var(--gr-primary); }

/* Role-tinted active states */
.theme-user .bottom-nav-link.active { color: var(--gr-primary); }
.theme-owner .bottom-nav-link.active { color: var(--gr-owner); }
.theme-admin .bottom-nav-link.active { color: var(--gr-admin); }
.theme-developer .bottom-nav-link.active { color: var(--gr-developer); }

/* Push content up so it doesn't hide behind the bottom nav */
@media (max-width: 900px) {
  .content { padding-bottom: 84px; }
  .auth-page .content { padding-bottom: 20px; }
}

/* ─── Passkey / WebAuthn UI ─────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--gr-border);
  border-top-color: var(--gr-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.spinner-sm {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
