/* ===========================
   GLOBAL
=========================== */
:root {
  --sidebar-width: 240px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --topbar-h: 60px;
  --primary: #2563eb;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --purple: #7c3aed;
  --body-bg: #f1f5f9;
  --card-radius: 12px;
}

* { box-sizing: border-box; }
body { background: var(--body-bg); font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; margin: 0; }

/* ===========================
   LOGIN
=========================== */
.login-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.login-wrapper { position: relative; z-index: 10; width: 100%; max-width: 420px; padding: 1.5rem; }
.login-card {
  background: white;
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 25px 60px rgba(0,0,0,0.4);
}
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-logo {
  width: 70px; height: 70px;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  font-size: 2rem; color: white;
  box-shadow: 0 8px 20px rgba(37,99,235,0.4);
}
.login-title { font-size: 1.6rem; font-weight: 800; color: #0f172a; margin: 0; }
.login-subtitle { color: #64748b; font-size: 0.9rem; margin: 0; }
.login-footer { margin-top: 1.5rem; text-align: center; }
.login-hint { background: #f8fafc; border-radius: 8px; padding: 0.6rem 1rem; font-size: 0.82rem; color: #64748b; display: inline-block; }
.login-bg-circle { position: fixed; border-radius: 50%; opacity: 0.08; pointer-events: none; }
.login-bg-circle-1 { width: 400px; height: 400px; background: #2563eb; top: -100px; right: -100px; }
.login-bg-circle-2 { width: 300px; height: 300px; background: #7c3aed; bottom: -80px; left: -80px; }
.login-bg-circle-3 { width: 200px; height: 200px; background: #16a34a; top: 40%; left: 40%; }

/* ===========================
   SIDEBAR
=========================== */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 1.2rem 1.2rem 0.8rem;
  color: white; font-size: 1.1rem; font-weight: 800;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--topbar-h);
}
.sidebar-brand i { color: #60a5fa; font-size: 1.3rem; }
.sidebar-toggle-btn { margin-left: auto; background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; }
.sidebar-user {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.9rem;
  flex-shrink: 0;
}
.sidebar-user-name { color: white; font-size: 0.85rem; font-weight: 600; line-height: 1.2; }
.sidebar-nav { flex: 1; padding: 0.5rem 0; }
.sidebar-section {
  color: rgba(255,255,255,0.3);
  font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.8rem 1.2rem 0.3rem;
  text-transform: uppercase;
}
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1.2rem;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 0;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { color: white; background: var(--sidebar-hover); }
.sidebar-link.active { color: white; background: rgba(37,99,235,0.25); border-left-color: var(--primary); }
.sidebar-link i { width: 18px; text-align: center; font-size: 0.9rem; }
.sidebar-footer {
  padding: 0.8rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 999;
}

/* ===========================
   MAIN CONTENT
=========================== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left 0.3s ease;
}
.page-content { padding: 1.5rem; flex: 1; }

/* ===========================
   TOPBAR
=========================== */
.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.topbar-toggle {
  background: none; border: none; color: #64748b;
  font-size: 1.1rem; cursor: pointer; padding: 0.4rem;
  border-radius: 6px;
  display: none;
}
.topbar-search { flex: 1; max-width: 400px; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.topbar-icon-btn {
  width: 36px; height: 36px; border-radius: 8px;
  background: none; border: 1px solid #e2e8f0;
  color: #64748b; cursor: pointer; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.topbar-icon-btn:hover { background: #f8fafc; color: var(--primary); }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: white;
  font-size: 0.6rem; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
.topbar-user-btn {
  display: flex; align-items: center; gap: 0.5rem;
  background: none; border: 1px solid #e2e8f0;
  border-radius: 8px; padding: 0.3rem 0.7rem;
  color: #374151; cursor: pointer; font-size: 0.85rem;
  transition: all 0.15s;
}
.topbar-user-btn:hover { background: #f8fafc; }
.topbar-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white; font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ===========================
   NOTIFICATIONS
=========================== */
.notif-dropdown { width: 340px; padding: 0; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; }
.notif-header { padding: 0.75rem 1rem; border-bottom: 1px solid #f1f5f9; background: #f8fafc; }
.notif-item {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.75rem 1rem;
  text-decoration: none; color: #374151;
  border-bottom: 1px solid #f8fafc;
  transition: background 0.1s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item.unread { background: #eff6ff; }
.notif-icon {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; flex-shrink: 0;
}
.notif-stock { background: #fef3c7; color: #d97706; }
.notif-appointment { background: #d1fae5; color: #059669; }
.notif-workorder { background: #dbeafe; color: #2563eb; }
.notif-info { background: #e0e7ff; color: #4f46e5; }
.notif-msg { font-size: 0.82rem; line-height: 1.4; }
.notif-time { font-size: 0.72rem; margin-top: 2px; }
.notif-empty { text-align: center; color: #94a3b8; padding: 1.5rem; font-size: 0.85rem; }

/* ===========================
   FLASH
=========================== */
.flash-container { padding: 0.75rem 1.5rem 0; }
.flash-container .alert { border-radius: 10px; border: none; }

/* ===========================
   PAGE HEADER
=========================== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: #0f172a; margin: 0; }

/* ===========================
   STAT CARDS
=========================== */
.stat-card {
  border-radius: var(--card-radius);
  padding: 1.25rem;
  color: white;
  position: relative; overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.stat-card::before {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(255,255,255,0.1);
}
.stat-icon { font-size: 1.8rem; opacity: 0.85; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1; margin-bottom: 0.25rem; }
.stat-label { font-size: 0.78rem; opacity: 0.85; font-weight: 500; }
.stat-card-blue  { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.stat-card-green { background: linear-gradient(135deg, #16a34a, #15803d); }
.stat-card-orange { background: linear-gradient(135deg, #d97706, #b45309); }
.stat-card-purple { background: linear-gradient(135deg, #7c3aed, #6d28d9); }
.stat-card-red { background: linear-gradient(135deg, #dc2626, #b91c1c); }

/* ===========================
   CARDS
=========================== */
.card { border: 1px solid #e2e8f0; border-radius: var(--card-radius); }
.card-header { padding: 0.875rem 1.25rem; }

/* ===========================
   TABLES
=========================== */
.table > :not(caption) > * > * { padding: 0.75rem 1rem; }
.table-danger-soft { background: #fff5f5 !important; }

/* ===========================
   BADGES & PLATES
=========================== */
.plate-badge {
  display: inline-block;
  background: #1e293b; color: white;
  font-weight: 800; font-size: 0.85rem;
  padding: 0.25rem 0.7rem;
  border-radius: 6px;
  letter-spacing: 0.08em;
  font-family: 'Courier New', monospace;
}
.plate-badge-sm {
  display: inline-block;
  background: #1e293b; color: white;
  font-weight: 700; font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.06em;
  font-family: 'Courier New', monospace;
}
.badge-sm { font-size: 0.65rem; padding: 0.2rem 0.4rem; }

/* ===========================
   CUSTOMER AVATARS
=========================== */
.customer-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white; font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.customer-avatar-lg {
  width: 70px; height: 70px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white; font-weight: 700; font-size: 1.8rem;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
}

/* ===========================
   INFO ROWS
=========================== */
.info-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f8fafc;
  font-size: 0.875rem;
}
.info-row:last-child { border-bottom: none; }
.info-row i { width: 16px; text-align: center; }

/* ===========================
   APPOINTMENTS
=========================== */
.appt-time-badge {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #1d4ed8);
  color: white; text-align: center; flex-shrink: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.appt-day { font-size: 1rem; font-weight: 800; line-height: 1; }
.appt-month { font-size: 0.6rem; text-transform: uppercase; opacity: 0.85; }
.appointment-card { transition: background 0.15s; }
.appointment-card:hover { background: #f8fafc; }

/* ===========================
   TIMELINE
=========================== */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: ''; position: absolute; left: 7px; top: 0; bottom: 0;
  width: 2px; background: #e2e8f0;
}
.timeline-item { position: relative; margin-bottom: 1rem; }
.timeline-dot {
  position: absolute; left: -1.5rem; top: 4px;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 2px #e2e8f0;
}
.timeline-content { background: #f8fafc; border-radius: 8px; padding: 0.5rem 0.75rem; }

/* ===========================
   STATUS BADGE COLORS
=========================== */
.bg-purple { background-color: var(--purple) !important; }
.opacity-60 { opacity: 0.6; }

/* ===========================
   PRINT STYLES
=========================== */
@media print {
  .sidebar, .topbar, .flash-container, .d-print-none,
  .page-header .btn, .card-footer { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  .page-content { padding: 0 !important; }
}

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0 !important; }
  .topbar-toggle { display: flex !important; }
  .page-content { padding: 1rem; }
  .stat-value { font-size: 1.2rem; }
  .page-title { font-size: 1.1rem; }
  .plate-badge { font-size: 0.75rem; }
}

@media (max-width: 576px) {
  .login-card { padding: 1.75rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ===========================
   FORM CONTROLS
=========================== */
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* ===========================
   PHOTO GALLERY
=========================== */
.photo-card { position: relative; }
.photo-card img { transition: transform 0.2s ease; cursor: pointer; border: 2px solid #e2e8f0; }
.photo-card img:hover { transform: scale(1.03); border-color: var(--primary); }
.photo-overlay {
  position: absolute; bottom: 4px; left: 4px;
  display: flex; gap: 4px; flex-wrap: wrap;
}

/* ===========================
   PART SEARCH DROPDOWN
=========================== */
.dropdown-results {
  position: absolute; z-index: 1000;
  background: white; border: 1px solid #e2e8f0;
  border-radius: 8px; max-height: 240px;
  overflow-y: auto; width: 100%; min-width: 280px;
}
.dropdown-result-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer; border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
.dropdown-result-item:hover { background: #f0f7ff; }
.dropdown-result-item:last-child { border-bottom: none; }

/* ===========================
   SCROLLBAR
=========================== */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
