/* ============================================
   GPH Dashboard - style.css
   Fully responsive – mobile-first approach
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --clr-primary: #2563eb;
  --clr-primary-dark: #1d4ed8;
  --clr-primary-light: #dbeafe;
  --clr-accent: #0ea5e9;
  --clr-bg: #f1f5f9;
  --clr-surface: #ffffff;
  --clr-text: #1e293b;
  --clr-text-muted: #64748b;
  --clr-border: #e2e8f0;
  --clr-success: #16a34a;
  --clr-warning: #f59e0b;
  --clr-danger: #dc2626;
  --sidebar-w: 260px;
  --navbar-h: 64px;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.1);
  --transition: .25s ease;

  /* Fluid spacing scale */
  --space-xs: clamp(.5rem, 1vw, .75rem);
  --space-sm: clamp(.75rem, 1.5vw, 1rem);
  --space-md: clamp(1rem, 2.5vw, 1.5rem);
  --space-lg: clamp(1.25rem, 3vw, 2rem);
  --space-xl: clamp(1.5rem, 4vw, 2.5rem);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  padding: var(--space-md);
}

.login-card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xl) var(--space-lg);
  width: 100%;
  max-width: 420px;
}

.login-card .logo {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.login-card .logo h1 {
  font-size: clamp(1.4rem, 4vw, 1.75rem);
  font-weight: 700;
  color: var(--clr-primary);
}

.login-card .logo p {
  color: var(--clr-text-muted);
  font-size: clamp(.8rem, 2vw, .9rem);
  margin-top: .25rem;
}

.login-footer {
  text-align: center;
  margin-top: var(--space-md);
  font-size: .85rem;
  color: var(--clr-text-muted);
}

.login-footer a {
  color: var(--clr-primary);
  font-weight: 600;
}

/* ============================================
   FORM ELEMENTS (shared)
   ============================================ */
.form-group {
  margin-bottom: var(--space-sm);
}

.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--clr-text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: .7rem 1rem;
  border: 1.5px solid var(--clr-border);
  border-radius: 8px;
  font-size: 1rem;          /* prevent iOS zoom */
  font-family: inherit;
  color: var(--clr-text);
  background: var(--clr-surface);
  transition: border var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;  /* consistent iOS styling */
  appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px var(--clr-primary-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;          /* touch target */
  transition: background var(--transition), transform var(--transition);
}

.btn:active { transform: scale(.97); }

.btn-primary { background: var(--clr-primary); color: #fff; }
.btn-primary:hover { background: var(--clr-primary-dark); }

.btn-block { width: 100%; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--clr-border);
  color: var(--clr-text);
}
.btn-outline:hover { background: var(--clr-bg); }

.btn-success { background: var(--clr-success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--clr-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ============================================
   LAYOUT – Sidebar + Navbar + Main
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;            /* dynamic viewport for mobile */
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-brand {
  padding: var(--space-md) var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-brand h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.sidebar-brand span {
  font-size: .75rem;
  color: #94a3b8;
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-sm) 0;
}

.nav-section-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  padding: .75rem 1.5rem .35rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.5rem;
  font-size: .9rem;
  border-left: 3px solid transparent;
  min-height: 44px;           /* touch target */
  transition: all var(--transition);
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,.05);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(37,99,235,.15);
  color: var(--clr-accent);
  border-left-color: var(--clr-accent);
}

.sidebar-nav a .icon {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
}

.sidebar-footer {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  color: #475569;
  flex-shrink: 0;
}

/* --- Main wrapper --- */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 0;              /* prevent flex child overflow */
}

/* --- Top Navbar --- */
.topnav {
  position: sticky;
  top: 0;
  height: var(--navbar-h);
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 50;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.topnav-left {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}

.topnav-left .page-title {
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--clr-text);
  padding: .25rem;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.topnav-right .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--clr-primary-light);
  color: var(--clr-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

.topnav-right .user-name {
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
}

/* --- Page Content --- */
.page-content {
  flex: 1;
  padding: var(--space-lg);
  width: 100%;
  max-width: 1400px;
}

/* ============================================
   STAT CARDS
   ============================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--clr-border);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: var(--space-xs);
}

.stat-card .stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-card .stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-card .stat-icon.amber  { background: #fef3c7; color: #d97706; }
.stat-card .stat-icon.purple { background: #ede9fe; color: #7c3aed; }

.stat-card h1 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
}

.stat-card p {
  color: var(--clr-text-muted);
  font-size: clamp(.78rem, 1.5vw, .85rem);
  margin-top: .15rem;
}

/* ============================================
   CARD (generic)
   ============================================ */
.card {
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--clr-border);
  overflow: hidden;           /* rounded corners clip children */
}

.card + .card {
  margin-top: var(--space-md);
}

.card-header {
  padding: var(--space-md) var(--space-md);
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
}

.card-header h2 {
  font-size: clamp(.95rem, 2vw, 1.1rem);
  font-weight: 600;
}

.card-body {
  padding: var(--space-md);
}

.card-body.no-pad { padding: 0; }

/* ============================================
   TABLE
   ============================================ */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 600px;           /* force horizontal scroll before cramping */
  border-collapse: collapse;
}

table thead th {
  text-align: left;
  padding: .85rem var(--space-md);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--clr-text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--clr-border);
  white-space: nowrap;
}

table tbody td {
  padding: .85rem var(--space-md);
  font-size: .9rem;
  border-bottom: 1px solid var(--clr-border);
  color: var(--clr-text);
}

table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-amber  { background: #fef3c7; color: #92400e; }

/* ============================================
   FORMS GRID (Add Car, etc.)
   ============================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xs) var(--space-md);
}

.form-grid .full-width { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: var(--space-sm);
}

/* ============================================
   CAR DETAIL
   ============================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm) var(--space-lg);
}

.detail-item label {
  display: block;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--clr-text-muted);
  margin-bottom: .2rem;
}

.detail-item span {
  font-size: 1rem;
  font-weight: 500;
  word-break: break-word;
}

/* ============================================
   PROFILE
   ============================================ */
.profile-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.profile-avatar {
  width: clamp(72px, 12vw, 96px);
  height: clamp(72px, 12vw, 96px);
  border-radius: 50%;
  background: var(--clr-primary-light);
  color: var(--clr-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  flex-shrink: 0;
}

.profile-info h2 {
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 700;
}

.profile-info p {
  color: var(--clr-text-muted);
  font-size: .9rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: .85rem 0;
  border-bottom: 1px solid var(--clr-border);
  font-size: .95rem;
}

.info-row:last-child { border-bottom: none; }
.info-row .info-label { color: var(--clr-text-muted); white-space: nowrap; }
.info-row .info-value { font-weight: 500; text-align: right; word-break: break-word; }

/* ============================================
   ADDED CAR CARD (preview after submit)
   ============================================ */
.car-preview-card {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1.5px solid #bfdbfe;
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-top: var(--space-md);
}

.car-preview-card h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-sm);
  color: var(--clr-primary);
}

/* ============================================
   MOBILE OVERLAY
   ============================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* --- Tablets / small desktops (≤1024px) --- */
@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Tablets / landscape phones (≤768px) --- */
@media (max-width: 768px) {

  /* Sidebar collapses off-screen */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }

  /* Remove sidebar margin */
  .main-wrapper {
    margin-left: 0;
  }

  /* Show hamburger */
  .hamburger {
    display: inline-flex;
  }

  /* Tighten navbar */
  .topnav {
    padding: 0 var(--space-sm);
  }

  /* Hide username on small screens */
  .topnav-right .user-name {
    display: none;
  }

  /* Form grid stacks */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Detail grid stacks */
  .detail-grid {
    grid-template-columns: 1fr;
  }

  /* Profile header stacks */
  .profile-header {
    flex-direction: column;
    text-align: center;
  }

  /* Info row stacks on very tight space */
  .info-row {
    flex-direction: column;
    gap: .2rem;
  }
  .info-row .info-value {
    text-align: left;
  }

  /* Button row wraps */
  .form-actions .btn {
    flex: 1 1 auto;
  }
}

/* --- Small phones (≤480px) --- */
@media (max-width: 480px) {

  /* Stat cards go single column */
  .stat-grid {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  /* Smaller stat numbers */
  .stat-card h1 {
    font-size: 1.5rem;
  }

  /* Tighter card padding */
  .card-header {
    padding: var(--space-sm);
  }
  .card-body {
    padding: var(--space-sm);
  }

  /* Login card tighter */
  .login-card {
    padding: var(--space-lg) var(--space-sm);
  }

  /* Full-width buttons on smallest screens */
  .form-actions {
    flex-direction: column;
  }
  .form-actions .btn {
    width: 100%;
  }

  /* Card header stacks if button present */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Table font smaller */
  table tbody td,
  table thead th {
    padding: .65rem var(--space-sm);
    font-size: .82rem;
  }
}

/* ============================================
   LANDSCAPE PHONE FIX
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
  .login-wrapper {
    align-items: flex-start;
    padding-top: var(--space-sm);
  }
  .sidebar {
    overflow-y: auto;
  }
}

/* ============================================
   LARGE SCREENS (≥1400px) – wider breathing
   ============================================ */
@media (min-width: 1400px) {
  .page-content {
    padding: var(--space-xl);
  }
  .stat-grid {
    gap: var(--space-lg);
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .sidebar,
  .topnav,
  .hamburger,
  .sidebar-overlay,
  .btn { display: none !important; }

  .main-wrapper { margin-left: 0; }
  .page-content { padding: 0; }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================
   ACCESSIBILITY – Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}