/* ==========================================================================
   Samad Motors - Executive Admin & Editorial Suite Stylesheet
   Modern, ultra-clean automotive dealership management cockpit
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
  --admin-bg: #09090b;
  --admin-surface: #121215;
  --admin-card: #18181b;
  --admin-border: #27272a;
  --admin-border-subtle: #202023;
  --admin-text-main: #f4f4f5;
  --admin-text-muted: #a1a1aa;
  --admin-text-dim: #71717a;
  --brand-red: #dc2626;
  --brand-red-hover: #b91c1c;
  --brand-red-glow: rgba(220, 38, 38, 0.25);
  --color-green: #10b981;
  --color-amber: #f59e0b;
  --color-blue: #3b82f6;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --font-base: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

body {
  font-family: var(--font-base);
  background-color: var(--admin-bg);
  color: var(--admin-text-main);
  line-height: 1.5;
  font-size: 13.5px;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Sidebar */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--admin-surface);
  border-right: 1px solid var(--admin-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--admin-border);
}

.sidebar-brand .brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.sidebar-brand .brand-title span {
  color: var(--brand-red);
}

.sidebar-brand .brand-sub {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--admin-text-dim);
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar-heading {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--admin-text-dim);
  padding: 0.75rem 0.65rem 0.35rem 0.65rem;
  margin-top: 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--admin-text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  color: var(--admin-text-dim);
  transition: color 0.15s ease;
  flex-shrink: 0;
}

.sidebar-link:hover {
  color: #ffffff;
  background: var(--admin-card);
}

.sidebar-link:hover svg {
  color: var(--brand-red);
}

.sidebar-link.active {
  color: #ffffff;
  background: rgba(220, 38, 38, 0.12);
  border-left: 3px solid var(--brand-red);
  font-weight: 600;
}

.sidebar-link.active svg {
  color: var(--brand-red);
}

.sidebar-badge {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: var(--admin-border);
  color: #cbd5e1;
  font-weight: 700;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  letter-spacing: 0.02em;
  min-width: 22px;
  box-sizing: border-box;
}

.sidebar-badge.badge-red {
  background: rgba(220, 38, 38, 0.22);
  color: #fca5a5;
  border: 1px solid rgba(220, 38, 38, 0.45);
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.2);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--admin-border);
  background: rgba(0, 0, 0, 0.2);
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--admin-border);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.user-details {
  line-height: 1.2;
  overflow: hidden;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-top: 2px;
}

.role-super {
  background: rgba(220, 38, 38, 0.2);
  color: #f87171;
  border: 1px solid rgba(220, 38, 38, 0.35);
}

.role-admin {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Main Content Area */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Topbar */
.admin-topbar {
  height: var(--topbar-h);
  background: rgba(18, 18, 21, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--admin-border);
  position: sticky;
  top: 0;
  z-index: 90;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.topbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  color: #ffffff;
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-page-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

/* Page Body */
.admin-content {
  padding: 1.75rem;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Page Header Title */
.page-header-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #ffffff;
  line-height: 1.2;
  margin-top: 0.25rem;
}

/* Common UI Elements */
.admin-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.metric-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--admin-border);
}

.metric-card.accent-red::after { background: var(--brand-red); }
.metric-card.accent-green::after { background: var(--color-green); }
.metric-card.accent-amber::after { background: var(--color-amber); }
.metric-card.accent-blue::after { background: var(--color-blue); }

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.metric-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--admin-text-muted);
}

.metric-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--admin-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--admin-text-main);
}

.metric-value {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin-bottom: 0.2rem;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--admin-text-dim);
}

/* Tables */
.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border: 1px solid var(--admin-border);
  border-radius: var(--radius-sm);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

.admin-table th {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.85rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--admin-text-muted);
  border-bottom: 1px solid var(--admin-border);
}

.admin-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--admin-border-subtle);
  vertical-align: middle;
}

.admin-table th.cell-nowrap,
.admin-table td.cell-nowrap,
.admin-table td:has(.badge-pill),
.admin-table td:has(.btn-admin) {
  white-space: nowrap;
}

.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   Badges & Status Indicators - High-End Luxury Cockpit
   ========================================================================== */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.28rem 0.68rem;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap !important;
  line-height: 1;
  flex-shrink: 0 !important;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
}

/* Status Dot Indicator with gentle ambient glow */
.badge-in-stock::before,
.badge-sold::before,
.badge-reserved::before,
.badge-coming-soon::before,
.badge-pending::before,
.badge-contacted::before,
.badge-booked::before,
.badge-closed::before {
  content: "";
  display: inline-block;
  width: 5.5px;
  height: 5.5px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 5px currentColor;
  flex-shrink: 0;
}

/* Specific Status Palettes */
.badge-in-stock,
.badge-booked { 
  background: rgba(16, 185, 129, 0.12); 
  color: #34d399; 
  border-color: rgba(16, 185, 129, 0.28); 
}

.badge-sold { 
  background: rgba(239, 68, 68, 0.12); 
  color: #f87171; 
  border-color: rgba(239, 68, 68, 0.28); 
}

.badge-reserved,
.badge-pending { 
  background: rgba(245, 158, 11, 0.12); 
  color: #fbbf24; 
  border-color: rgba(245, 158, 11, 0.28); 
}

.badge-coming-soon,
.badge-contacted { 
  background: rgba(59, 130, 246, 0.12); 
  color: #60a5fa; 
  border-color: rgba(59, 130, 246, 0.28); 
}

.badge-closed { 
  background: rgba(113, 113, 122, 0.14); 
  color: #a1a1aa; 
  border-color: rgba(113, 113, 122, 0.25); 
}

.badge-featured { 
  background: rgba(220, 38, 38, 0.15); 
  color: #f87171; 
  border-color: rgba(220, 38, 38, 0.35); 
}

/* Buttons */
.btn-admin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-admin-primary {
  background: var(--brand-red);
  color: #ffffff;
  border-color: var(--brand-red);
}

.btn-admin-primary:hover {
  background: var(--brand-red-hover);
  border-color: var(--brand-red-hover);
}

.btn-admin-outline {
  background: transparent;
  color: var(--admin-text-main);
  border-color: var(--admin-border);
}

.btn-admin-outline:hover {
  background: var(--admin-card);
  border-color: var(--admin-text-muted);
}

.btn-admin-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-admin-danger:hover {
  background: #dc2626;
  color: #ffffff;
}

.btn-admin-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

/* Forms */
.form-group-admin {
  margin-bottom: 1.25rem;
}

.form-label-admin {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--admin-text-muted);
  margin-bottom: 0.4rem;
}

.form-control-admin {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--admin-border);
  background: var(--admin-bg);
  color: var(--admin-text-main);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-control-admin:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 2px var(--brand-red-glow);
}

.form-control-admin[readonly], .form-control-admin:disabled {
  background: rgba(0, 0, 0, 0.2);
  color: var(--admin-text-dim);
}

/* Dark Theme Browser Autofill Normalization (Chrome, Edge, Safari, Firefox) */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px #18181b inset !important;
  -webkit-text-fill-color: #f4f4f5 !important;
  caret-color: #f4f4f5 !important;
  border-color: #27272a !important;
  transition: background-color 5000s ease-in-out 0s;
}

input:-webkit-autofill:focus {
  border-color: var(--brand-red) !important;
  box-shadow: 0 0 0 1000px #18181b inset, 0 0 0 2px var(--brand-red-glow) !important;
}

/* Password Field with Show/Hide Toggle */
.password-field-wrapper {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
}

.password-field-wrapper .form-control-admin {
  padding-right: 2.85rem !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.password-toggle-btn {
  position: absolute !important;
  right: 0.5rem !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: transparent !important;
  background-color: transparent !important;
  border: 0 !important;
  border-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  color: #a1a1aa !important;
  cursor: pointer !important;
  padding: 0 !important;
  margin: 0 !important;
  width: 32px !important;
  height: 32px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 6px !important;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.1s ease !important;
  z-index: 5 !important;
  user-select: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  line-height: 1 !important;
}

.password-toggle-btn:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
  background-color: rgba(255, 255, 255, 0.08) !important;
}

.password-toggle-btn:active {
  transform: translateY(-50%) scale(0.92) !important;
}

.password-toggle-btn:focus-visible {
  outline: 2px solid var(--brand-red) !important;
  color: #ffffff !important;
}

.password-toggle-btn svg {
  width: 18px !important;
  height: 18px !important;
  pointer-events: none !important;
  stroke: currentColor !important;
}

.password-toggle-btn .icon-eye-show {
  display: block !important;
}

.password-toggle-btn .icon-eye-hide {
  display: none !important;
}

.password-toggle-btn.is-active .icon-eye-show {
  display: none !important;
}

.password-toggle-btn.is-active .icon-eye-hide {
  display: block !important;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--admin-text-dim);
  margin-top: 0.35rem;
}

/* Alert Boxes */
.admin-alert {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.alert-success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Grids */
.photo-upload-grid {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 1.5rem;
  align-items: start;
}

.users-management-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.5rem;
  align-items: start;
}

/* Sidebar Backdrop on Mobile */
.admin-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.admin-sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Responsive Dashboard Layout */
.dashboard-tables-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 1.5rem;
}

@media (max-width: 1200px) {
  .dashboard-tables-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile responsive */
@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-main {
    margin-left: 0;
    min-width: 0;
  }
  .mobile-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .form-grid-2, .form-grid-3,
  .photo-upload-grid,
  .users-management-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 13px;
  }
  .admin-topbar {
    height: 52px;
    padding: 0 0.85rem;
    gap: 0.5rem;
  }
  .topbar-title-wrap {
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
  }
  .topbar-page-title {
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
  }
  .mobile-nav-toggle {
    padding: 0.3rem;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }
  .mobile-nav-toggle svg {
    width: 17px;
    height: 17px;
  }
  .topbar-actions {
    display: none !important;
  }
  .admin-content {
    padding: 1rem 0.85rem;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.25rem;
  }
  .metric-card {
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-sm);
  }
  .metric-header {
    margin-bottom: 0.35rem;
  }
  .metric-label {
    font-size: 0.6rem;
    letter-spacing: 0.04em;
    font-weight: 600;
    line-height: 1.25;
  }
  .metric-icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    flex-shrink: 0;
  }
  .metric-icon svg {
    width: 12px;
    height: 12px;
  }
  .metric-value {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 0.15rem;
    line-height: 1.15;
  }
  .metric-sub {
    font-size: 0.65rem;
    line-height: 1.25;
  }
  .admin-card {
    padding: 0.95rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
  }
  .card-title {
    font-size: 0.85rem;
  }
  .card-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
  }
  .card-header-row .btn-admin {
    width: 100%;
    justify-content: center;
    font-size: 0.74rem;
  }
  .admin-table th {
    padding: 0.6rem 0.7rem;
    font-size: 0.64rem;
  }
  .admin-table td {
    padding: 0.6rem 0.7rem;
    font-size: 0.75rem;
  }
  .badge-pill {
    font-size: 0.6rem;
    padding: 0.2rem 0.45rem;
  }
  .btn-admin {
    font-size: 0.74rem;
    padding: 0.4rem 0.75rem;
  }
  .btn-admin-sm {
    font-size: 0.68rem;
    padding: 0.26rem 0.48rem;
  }
  .form-label-admin {
    font-size: 0.68rem;
    margin-bottom: 0.3rem;
  }
  .form-control-admin {
    font-size: 0.8rem;
    padding: 0.55rem 0.75rem;
  }
  .form-group-admin {
    margin-bottom: 0.95rem;
  }
  .page-header-title {
    font-size: 1.05rem;
  }
  .save-settings-btn {
    width: 100% !important;
    justify-content: center !important;
  }
}

@media (max-width: 420px) {
  .topbar-page-title {
    font-size: 0.82rem;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  .metric-card {
    padding: 0.75rem 0.9rem;
  }
  .metric-value {
    font-size: 1.25rem;
  }
}
