/* ============================================================
   Kirks Tire Service Dispatch - Main Stylesheet
   IBM Plex Sans + dark sidebar + clean content area
   Mobile-first, works on all screen sizes
   ============================================================ */

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

:root {
  /* Brand */
  --brand-navy:    #0f1923;
  --brand-gold:    #c9a227;
  --brand-gold-lt: #f0c84a;

  /* Sidebar */
  --sb-bg:         #0f1923;
  --sb-border:     rgba(255,255,255,0.07);
  --sb-text:       rgba(255,255,255,0.65);
  --sb-text-hover: rgba(255,255,255,0.95);
  --sb-active-bg:  rgba(201,162,39,0.15);
  --sb-active-text:#c9a227;
  --sb-width:      240px;

  /* Content */
  --bg:            #f4f3f0;
  --surface:       #ffffff;
  --border:        #e2e0da;
  --border-strong: #c8c6c0;

  /* Text */
  --text:          #1a1917;
  --text-muted:    #6b6a65;
  --text-faint:    #9b9a95;

  /* Status colors */
  --red:           #E24B4A;   --red-bg:    #FCEBEB;
  --amber:         #EF9F27;   --amber-bg:  #FAEEDA;
  --green:         #639922;   --green-bg:  #EAF3DE;
  --blue:          #378ADD;   --blue-bg:   #E6F1FB;
  --purple:        #7F77DD;   --purple-bg: #EEEDFE;

  /* Spacing */
  --r-sm:  6px;
  --r-md:  8px;
  --r-lg:  12px;
  --r-xl:  16px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);

  /* Typography */
  --font: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* -- App layout --------------------------------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* -- Sidebar ------------------------------------------------ */
.sidebar {
  width: var(--sb-width);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform 0.25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sb-border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-kt {
  width: 36px; height: 36px;
  background: var(--brand-gold);
  color: var(--brand-navy);
  font-size: 13px; font-weight: 600;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.logo-text { display: flex; flex-direction: column; gap: 1px; }
.logo-title { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.logo-sub   { font-size: 10px; color: var(--sb-text); line-height: 1.2; letter-spacing: 0.3px; }

.sidebar-close {
  display: none;
  background: none; border: none;
  color: var(--sb-text); font-size: 22px;
  cursor: pointer; padding: 4px; line-height: 1;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sb-border);
}

.user-avatar {
  width: 32px; height: 32px;
  background: rgba(201,162,39,0.2);
  color: var(--brand-gold-lt);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.user-name  { font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 11px; color: var(--sb-text); }

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--sb-text);
  padding: 12px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  color: var(--sb-text);
  font-size: 13.5px;
  font-weight: 400;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--sb-text-hover); text-decoration: none; }
.nav-item:hover svg { opacity: 1; }
.nav-item.active { background: var(--sb-active-bg); color: var(--sb-active-text); font-weight: 500; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 8px 8px 16px;
  border-top: 1px solid var(--sb-border);
}

.nav-logout { color: rgba(255,255,255,0.4); margin-top: 4px; }
.nav-logout:hover { color: #f09595; background: rgba(226,75,74,0.1); }

/* -- Mobile header ------------------------------------------ */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--sb-bg);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  border-bottom: 1px solid var(--sb-border);
}

.menu-toggle {
  background: none; border: none;
  cursor: pointer; padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
}

.menu-toggle span {
  display: block; width: 20px; height: 2px;
  background: rgba(255,255,255,0.7); border-radius: 2px;
}

.mobile-title { font-size: 14px; font-weight: 500; color: rgba(255,255,255,0.9); }

.mobile-new-btn {
  width: 30px; height: 30px;
  background: var(--brand-gold); color: var(--brand-navy);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 400; line-height: 1;
  text-decoration: none;
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}

/* -- Main content ------------------------------------------- */
.main-content {
  flex: 1;
  margin-left: var(--sb-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  padding: 28px 32px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title { font-size: 20px; font-weight: 600; color: var(--text); }

.page-body { padding: 20px 32px 40px; }

/* -- Cards -------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 20px 24px; }

.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title { font-size: 14px; font-weight: 600; }

/* -- Buttons ------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:active { opacity: 0.88; transform: scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary  { background: var(--brand-navy); color: #fff; border-color: var(--brand-navy); }
.btn-primary:hover  { background: #1a2a38; }

.btn-gold     { background: var(--brand-gold); color: var(--brand-navy); border-color: var(--brand-gold); }
.btn-gold:hover { background: var(--brand-gold-lt); }

.btn-outline  { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--bg); }

.btn-danger   { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #c43a39; }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

/* -- Forms -------------------------------------------------- */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}

label .required { color: var(--red); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 3px rgba(15,25,35,0.1);
}

input[disabled], select[disabled], textarea[disabled] {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236b6a65' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 32px;
}

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

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-hint  { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }

/* Checkbox / radio */
.check-group { display: flex; flex-direction: column; gap: 8px; }
.check-item  { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check-item input[type="checkbox"],
.check-item input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--brand-navy);
  flex-shrink: 0; margin-top: 2px;
  cursor: pointer;
}
.check-item span { font-size: 13.5px; line-height: 1.4; }

/* -- Tables ------------------------------------------------- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafaf8; }

/* -- Badges ------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success { background: var(--green-bg); color: var(--green); }
.badge-warning { background: var(--amber-bg); color: #854F0B; }
.badge-danger  { background: var(--red-bg);   color: #A32D2D; }
.badge-info    { background: var(--blue-bg);  color: #185FA5; }
.badge-default { background: #F1EFE8;         color: #5F5E5A; }
.badge-purple  { background: var(--purple-bg);color: #3C3489; }

/* -- Alerts ------------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success { background: var(--green-bg); color: #3B6D11; border-color: #C0DD97; }
.alert-error   { background: var(--red-bg);   color: #A32D2D; border-color: #F7C1C1; }
.alert-warning { background: var(--amber-bg); color: #854F0B; border-color: #FAC775; }
.alert-info    { background: var(--blue-bg);  color: #185FA5; border-color: #B5D4F4; }

/* -- Priority indicators ------------------------------------ */
.priority-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.priority-high     { background: var(--red);   }
.priority-moderate { background: var(--amber); }
.priority-low      { background: var(--green); }

/* -- Auth pages --------------------------------------------- */
.auth-page {
  background: var(--brand-navy);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 36px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.auth-logo .logo-kt {
  width: 48px; height: 48px;
  font-size: 16px;
  border-radius: var(--r-lg);
}

.auth-card h2 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }

/* -- Utility ------------------------------------------------ */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.text-muted  { color: var(--text-muted); }
.text-faint  { color: var(--text-faint); }
.text-sm     { font-size: 12.5px; }
.text-right  { text-align: right; }
.text-center { text-align: center; }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-1       { gap: 8px; }
.gap-2       { gap: 16px; }

.w-full      { width: 100%; }
.hidden      { display: none !important; }

/* -- Stats grid (dashboard) --------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 20px;
}

.stat-label { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--text); line-height: 1.1; }
.stat-sub   { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* -- Responsive --------------------------------------------- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }
  .sidebar-close { display: block; }
  .sidebar-overlay.open { display: block; }

  .mobile-header { display: flex; }

  .main-content { margin-left: 0; padding-top: 52px; }

  .page-header { padding: 20px 16px 0; }
  .page-body   { padding: 16px 16px 32px; }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  .auth-card { padding: 28px 24px; }
}
