/* ============================================================
   SHOP MANAGER — MAIN STYLESHEET
   ============================================================ */

:root {
  --sidebar-w: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08);
  --topbar-h: 64px;
}

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

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ── LAYOUT ─────────────────────────────────────────────────── */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  transition: transform .3s ease;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1e293b;
  text-decoration: none;
}

.sidebar-brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 10px;
  background: transparent;
  padding: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-title {
  color: #f8fafc;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.sidebar-brand-sub {
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  list-style: none;
  margin: 0;
}

.sidebar-section-label {
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 16px 20px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 0;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.sidebar-nav a.active {
  background: linear-gradient(90deg, rgba(37,99,235,.25) 0%, rgba(37,99,235,.05) 100%);
  color: #93c5fd;
  border-left: 3px solid var(--accent);
  padding-left: 17px;
}

.sidebar-nav a .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: #64748b;
  font-size: 11px;
}

.sidebar-logout {
  color: #64748b;
  text-decoration: none;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s;
}

.sidebar-logout:hover {
  color: #ef4444;
}

/* ── SIDEBAR OVERLAY (mobile) ──────────────────────────────── */

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

.sidebar-overlay.active {
  display: block;
}

/* ── MAIN CONTENT ────────────────────────────────────────────── */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */

.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: none;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-toggle {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 8px;
  display: none;
  font-size: 18px;
  transition: background .15s;
}

.topbar-toggle:hover {
  background: var(--body-bg);
  color: var(--text);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── PAGE CONTENT ────────────────────────────────────────────── */

.page-content {
  flex: 1;
  padding: 24px;
}

/* ── PAGE HEADER ─────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header-left h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}

.page-header-left p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── CARDS ───────────────────────────────────────────────────── */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.card-header h5 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

/* ── STAT CARDS ──────────────────────────────────────────────── */

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow .2s, transform .2s;
  text-decoration: none;
  color: inherit;
}

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

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue  { background: #dbeafe; color: #2563eb; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.red   { background: #fee2e2; color: #dc2626; }
.stat-icon.purple{ background: #ede9fe; color: #7c3aed; }
.stat-icon.teal  { background: #ccfbf1; color: #0d9488; }

.stat-info h3 {
  font-size: 28px;
  font-weight: 800;
  margin: 0;
  line-height: 1;
}

.stat-info span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

/* ── TABLES ──────────────────────────────────────────────────── */

.table-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.table tbody tr:hover {
  background: #f8fafc;
}

/* ── BADGES ──────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success  { background: #dcfce7; color: #15803d; }
.badge-danger   { background: #fee2e2; color: #b91c1c; }
.badge-warning  { background: #fef3c7; color: #b45309; }
.badge-info     { background: #e0f2fe; color: #0369a1; }
.badge-primary  { background: #dbeafe; color: #1d4ed8; }
.badge-secondary{ background: #f1f5f9; color: #475569; }
.badge-purple   { background: #ede9fe; color: #6d28d9; }
.badge-teal     { background: #ccfbf1; color: #0f766e; }
.badge-dark     { background: #1e293b; color: #94a3b8; }

/* status-specific */
.status-Scheduled     { background: #e0f2fe; color: #0369a1; }
.status-On-Site-Visit { background: #fef9c3; color: #854d0e; }
.status-Received      { background: #f3e8ff; color: #6b21a8; }
.status-Diagnosing    { background: #fef3c7; color: #92400e; }
.status-Waiting-Parts { background: #fee2e2; color: #9f1239; }
.status-Repairing     { background: #dbeafe; color: #1e40af; }
.status-Completed     { background: #dcfce7; color: #166534; }
.status-Collected     { background: #f0fdf4; color: #15803d; }
.status-Cancelled     { background: #f1f5f9; color: #64748b; }

/* ticket statuses */
.status-Open            { background: #fee2e2; color: #b91c1c; }
.status-In-Progress     { background: #dbeafe; color: #1d4ed8; }
.status-Waiting-Customer{ background: #fef3c7; color: #b45309; }
.status-Resolved        { background: #dcfce7; color: #15803d; }
.status-Closed          { background: #f1f5f9; color: #475569; }

/* ── BUTTONS ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, box-shadow .15s, transform .1s;
  white-space: nowrap;
  line-height: 1;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }

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

.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; color: #fff; }

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

.btn-info      { background: var(--info); color: #fff; }
.btn-info:hover { background: #0e7490; color: #fff; }

.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; color: var(--text); }

.btn-outline-primary { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline-primary:hover { background: var(--accent); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 6px; gap: 5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ── FORMS ───────────────────────────────────────────────────── */

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control, .form-select {
  display: block;
  width: 100%;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--text);
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.form-group { margin-bottom: 16px; }

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.input-group {
  display: flex;
  gap: 0;
}

.input-group .form-control {
  border-radius: 8px 0 0 8px;
}

.input-group .btn {
  border-radius: 0 8px 8px 0;
}

/* ── ALERTS ──────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* ── QUICK ACTION CARDS ──────────────────────────────────────── */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 16px;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: all .2s;
  text-align: center;
}

.action-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 12px rgba(37,99,235,.12);
  transform: translateY(-2px);
  text-decoration: none;
}

.action-card .action-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.action-icon.blue   { background: #dbeafe; color: #2563eb; }
.action-icon.green  { background: #dcfce7; color: #16a34a; }
.action-icon.amber  { background: #fef3c7; color: #d97706; }
.action-icon.purple { background: #ede9fe; color: #7c3aed; }
.action-icon.teal   { background: #ccfbf1; color: #0d9488; }
.action-icon.red    { background: #fee2e2; color: #dc2626; }

/* ── DETAIL PAIRS ────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.detail-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.detail-section {
  margin-bottom: 24px;
}

.detail-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── SEARCH BAR ──────────────────────────────────────────────── */

.search-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input-wrap .form-control {
  padding-left: 38px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

/* ── PRIORITY BADGES ─────────────────────────────────────────── */

.priority-Low    { background: #f1f5f9; color: #475569; }
.priority-Medium { background: #fef3c7; color: #b45309; }
.priority-High   { background: #fee2e2; color: #b91c1c; }
.priority-Urgent { background: #fef2f2; color: #7f1d1d; border: 1.5px solid #fca5a5; }

/* ── PAGINATION / EMPTY STATE ────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: .4;
}

.empty-state h5 {
  margin: 0 0 8px;
  color: var(--text);
  font-weight: 600;
}

.empty-state p {
  margin: 0;
  font-size: 13px;
}

/* ── MOBILE ──────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Sidebar */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .topbar-toggle {
    display: flex;
  }

  /* Spacing */
  .page-content {
    padding: 12px;
  }
  .card-body {
    padding: 14px;
  }
  .card-header {
    padding: 12px 14px;
  }

  /* Page header stacks */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header-left h1 {
    font-size: 20px;
  }

  /* Quick actions 2 columns */
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .action-card {
    padding: 14px 10px;
    gap: 7px;
    font-size: 12px;
  }

  /* Detail grid 1 column */
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Tables — scroll horizontally, hide less-important columns */
  .table-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table thead th,
  .table tbody td {
    padding: 10px 12px;
    font-size: 13px;
    white-space: nowrap;
  }
  /* Hide lower-priority columns on mobile */
  .hide-mobile {
    display: none !important;
  }
  /* Action buttons — icon only on mobile */
  .btn-mobile-icon {
    padding: 6px 8px !important;
    gap: 0 !important;
  }
  .btn-mobile-icon .btn-label {
    display: none;
  }

  /* Stat cards */
  .stat-card {
    padding: 14px 16px;
    gap: 12px;
  }
  .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 17px;
  }
  .stat-info h3 {
    font-size: 22px;
  }

  /* Search bar stacks */
  .search-bar {
    flex-direction: column;
  }
  .search-input-wrap {
    min-width: unset;
  }

  /* Buttons wrap on mobile */
  .btn-group-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Bootstrap row columns fix */
  .col-md-3, .col-md-4, .col-md-6 {
    width: 100%;
  }

  /* Login box */
  .login-box {
    padding: 28px 20px;
  }

  /* Topbar — only visible on mobile for the hamburger */
  .topbar {
    display: flex;
    padding: 0 14px;
    height: 52px;
  }
}

@media (max-width: 480px) {
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-card {
    flex-direction: row;
    padding: 12px 14px;
  }
  .page-content {
    padding: 10px;
  }
  /* Stack multi-button rows vertically */
  .action-btn-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── UTILITIES ───────────────────────────────────────────────── */

.text-muted   { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--accent) !important; }
.fw-bold      { font-weight: 700; }
.fw-semibold  { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.text-end { text-align: right; }
.text-center { text-align: center; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── LOGIN PAGE ──────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo img {
  width: 90px;
  height: 90px;
  object-fit: contain;
  border-radius: 16px;
  background: transparent;
  padding: 0;
  margin-bottom: 12px;
}

.login-logo h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  color: var(--text);
}

.login-logo p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}
