/* ============================================================
   MRS - Maintenance Request System
   Custom Stylesheet — Responsive Edition
   Breakpoints: xs<576 | sm 576-767 | md 768-991 | lg≥992
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #818cf8;
  --secondary: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --dark: #0f172a;
  --sidebar-w: 260px;
  --sidebar-bg: #1e1b4b;
  --sidebar-hover: rgba(255, 255, 255, .07);
  --topbar-h: 64px;
  --card-radius: 16px;
  --card-shadow: 0 4px 24px rgba(0, 0, 0, .07);
  --transition: .2s ease;
  --bottom-nav-h: 60px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  /* Prevent scroll jump when page loads after clicking internal links */
  scroll-behavior: auto;
  overflow-x: hidden;
}

body {
  font-family: 'Sarabun', 'Inter', sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  font-size: 15px;
  /* Prevent horizontal overflow on mobile */
  overflow-x: hidden;
  /* Prevent page jump on navigation */
  position: relative;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

/* ============================================================
   Layout
   ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1050;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
  /* Smooth sidebar transform on all platforms */
  will-change: transform;
  /* Prevent scroll-to-top when clicking links */
  overscroll-behavior: contain;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  line-height: 1.2;
}

.sidebar-brand .brand-title {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

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

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  /* Better momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  font-size: 14px;
  position: relative;
  /* Larger tap target on mobile */
  min-height: 44px;
  /* Prevent scroll jump when clicking */
  scroll-behavior: auto;
}

.sidebar-link i {
  font-size: 18px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--primary-light);
  border-radius: 0 4px 4px 0;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding: 12px 16px;
  flex-shrink: 0;
}

/* User card — clickable → profile */
.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  transition: background .2s, border-color .2s;
  margin-bottom: 8px;
}
.sidebar-user-card:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.18);
}

.suf-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.25);
}
.suf-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.suf-info {
  flex: 1;
  min-width: 0;
}
.suf-name {
  font-weight: 600;
  font-size: 12.5px;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suf-role {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suf-dept {
  font-size: 10.5px;
  color: rgba(255,255,255,.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suf-arrow {
  font-size: 11px;
  color: rgba(255,255,255,.3);
  flex-shrink: 0;
}

/* Action row — help + logout */
.suf-actions {
  display: flex;
  gap: 6px;
}
.suf-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 6px;
  border-radius: 9px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.55);
  font-size: 11.5px;
  text-decoration: none;
  transition: background .2s, color .2s;
}
.suf-action-btn:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.suf-logout:hover {
  background: rgba(239,68,68,.18);
  border-color: rgba(239,68,68,.3);
  color: #fca5a5;
}
.suf-action-btn i { font-size: 13px; }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin var(--transition);
  min-width: 0;
  /* Prevent flex overflow */
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .04);
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-spacer {
  flex: 1;
  min-width: 0;
}

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

.btn-icon {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
  position: relative;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  flex-shrink: 0;
  /* Touch-friendly */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ── Page content ── */
.page-content {
  padding: 28px;
  flex: 1;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
}

.page-header p {
  color: #64748b;
  font-size: 14px;
  margin-top: 2px;
}

/* ── Cards ── */
.card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid #f1f5f9;
}

.card-header {
  padding: 18px 20px 0;
  font-weight: 600;
  font-size: 15px;
  color: #1e293b;
  border-bottom: none;
  background: transparent;
}

.card-body {
  padding: 20px;
}

/* ── Stat Cards ── */
.stat-card {
  background: #fff;
  border-radius: var(--card-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--card-shadow);
  border: 1px solid #f1f5f9;
  transition: transform var(--transition), box-shadow var(--transition);
  height: 100%;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .1);
}

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

.stat-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.stat-trend {
  font-size: 12px;
  color: #64748b;
}

/* ── Badges ── */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
}

.priority-urgent {
  background: #fee2e2;
  color: #dc2626;
}

.priority-high {
  background: #fef3c7;
  color: #d97706;
}

.priority-medium {
  background: #dbeafe;
  color: #2563eb;
}

.priority-low {
  background: #f1f5f9;
  color: #64748b;
}

/* ========== Modern Status Badges ========== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid;
  transition: all 0.2s ease;
}

.status-badge::before {
  font-family: 'bootstrap-icons';
  font-size: 1rem;
  font-weight: normal;
}

/* Draft - Gray */
.status-badge.st-draft {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: #6c757d;
  border-color: #dee2e6;
}
.status-badge.st-draft::before {
  content: '\f34b'; /* bi-file-earmark-text */
}

/* Pending - Yellow/Orange */
.status-badge.st-pending {
  background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
  color: #997404;
  border-color: #ffc107;
}
.status-badge.st-pending::before {
  content: '\f4d0'; /* bi-hourglass-split */
}

/* Revision Requested - Orange Warning */
.status-badge.st-revision_requested {
  background: linear-gradient(135deg, #ffe5d0 0%, #ffd4a8 100%);
  color: #c66900;
  border-color: #ff9800;
}
.status-badge.st-revision_requested::before {
  content: '\f337'; /* bi-pencil-square */
}

/* Approved L1 - Light Blue */
.status-badge.st-approved_l1 {
  background: linear-gradient(135deg, #cfe2ff 0%, #9ec5fe 100%);
  color: #084298;
  border-color: #0d6efd;
}
.status-badge.st-approved_l1::before {
  content: '\f26b'; /* bi-check-circle */
}

/* Approved L2 - Blue */
.status-badge.st-approved_l2 {
  background: linear-gradient(135deg, #b6d4fe 0%, #84b6f4 100%);
  color: #052c65;
  border-color: #0a58ca;
}
.status-badge.st-approved_l2::before {
  content: '\f26c'; /* bi-check-circle-fill */
}

/* Approved L3 - Deeper Blue */
.status-badge.st-approved_l3 {
  background: linear-gradient(135deg, #9ec5fe 0%, #6ea8fe 100%);
  color: #052c65;
  border-color: #0d6efd;
}
.status-badge.st-approved_l3::before {
  content: '\f26c'; /* bi-check-circle-fill */
}

/* Approved Final - Indigo */
.status-badge.st-approved_final {
  background: linear-gradient(135deg, #c5dbff 0%, #a2c4ff 100%);
  color: #0a3d80;
  border-color: #3366cc;
}
.status-badge.st-approved_final::before {
  content: '\f5e0'; /* bi-patch-check-fill */
}

/* Technical Review - Purple */
.status-badge.st-technical_review {
  background: linear-gradient(135deg, #e0cffc 0%, #d1b3ff 100%);
  color: #6f42c1;
  border-color: #a855f7;
}
.status-badge.st-technical_review::before {
  content: '\f4c6'; /* bi-search */
}

/* Engineering Reviewed - Teal */
.status-badge.st-eng_reviewed {
  background: linear-gradient(135deg, #b8f0ea 0%, #8de4d3 100%);
  color: #0d8a72;
  border-color: #14b8a6;
}
.status-badge.st-eng_reviewed::before {
  content: '\f2a0'; /* bi-clipboard-check */
}

/* In Progress - Blue Primary */
.status-badge.st-in_progress {
  background: linear-gradient(135deg, #b6d4fe 0%, #84b6f4 100%);
  color: #0a3d80;
  border-color: #0d6efd;
}
.status-badge.st-in_progress::before {
  content: '\f465'; /* bi-gear-fill */
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Work Finished - Light Green */
.status-badge.st-work_finished {
  background: linear-gradient(135deg, #d1e7dd 0%, #a3cfbb 100%);
  color: #0a3622;
  border-color: #198754;
}
.status-badge.st-work_finished::before {
  content: '\f5e1'; /* bi-patch-check */
}

/* Completed - Green */
.status-badge.st-completed {
  background: linear-gradient(135deg, #badbcc 0%, #7bc99c 100%);
  color: #0a3622;
  border-color: #198754;
}
.status-badge.st-completed::before {
  content: '\f633'; /* bi-check-circle-fill */
}

/* Rejected - Red */
.status-badge.st-rejected {
  background: linear-gradient(135deg, #f8d7da 0%, #f1aeb5 100%);
  color: #842029;
  border-color: #dc3545;
}
.status-badge.st-rejected::before {
  content: '\f62f'; /* bi-x-circle-fill */
}

/* Cancelled - Dark Gray */
.status-badge.st-cancelled {
  background: linear-gradient(135deg, #d6d8db 0%, #b8bcc2 100%);
  color: #2c2f33;
  border-color: #6c757d;
}
.status-badge.st-cancelled::before {
  content: '\f5db'; /* bi-slash-circle */
}

/* ── Tables ── */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}

.table-modern {
  width: 100%;
  border-collapse: collapse;
}

.table-modern th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 12px 14px;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.table-modern td {
  padding: 13px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
  vertical-align: middle;
}

.table-modern tbody tr:hover {
  background: #fafbfd;
}

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

/* ── Mobile Card Table ──
   When .mobile-card-table is used, JS injects data-label from <th>
   and on mobile each row turns into a card
   ── */
@media (max-width: 767px) {
  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table tbody tr {
    display: block;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .05);
  }

  .mobile-card-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .mobile-card-table tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid #f1f5f9;
    padding: 8px 4px;
    font-size: 13px;
    flex-wrap: wrap;
  }

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

  .mobile-card-table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #94a3b8;
    white-space: nowrap;
    min-width: 80px;
    flex-shrink: 0;
  }

  /* Action column: no label, centered */
  .mobile-card-table tbody td:last-child::before {
    display: none;
  }

  .mobile-card-table tbody td:last-child {
    justify-content: flex-end;
  }

  /* Hide low-priority columns on mobile */
  .mobile-card-table td.d-mobile-none,
  .mobile-card-table th.d-mobile-none {
    display: none !important;
  }
}

/* ── Form ── */
.form-label {
  font-weight: 600;
  font-size: 13px;
  color: #374151;
  margin-bottom: 6px;
}

.form-control,
.form-select {
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  /* Better on iOS */
  -webkit-appearance: none;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 16px 12px;
  padding-right: 2.5rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
  outline: none;
}

.form-text {
  font-size: 12px;
  color: #94a3b8;
}

/* ── Buttons ── */
.btn {
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 18px;
  transition: all var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /* Touch-friendly */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

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

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

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
  background: transparent;
}

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

.btn-outline-secondary {
  color: #64748b;
  border-color: #e2e8f0;
  background: transparent;
}

.btn-outline-secondary:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.btn-outline-warning {
  color: #d97706;
  border-color: #d97706;
  background: transparent;
}

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

.btn-outline-success {
  color: var(--success);
  border-color: var(--success);
  background: transparent;
}

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

.btn-outline-danger {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}

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

/* ── Timeline (Approval history) ── */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e2e8f0;
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
}

.timeline-dot.approved {
  background: var(--success);
}

.timeline-dot.rejected {
  background: var(--danger);
}

.timeline-dot.pending {
  background: #d1d5db;
  border: 2px solid #e2e8f0;
}

.timeline-body {
  background: #f8fafc;
  border-radius: 10px;
  padding: 12px 14px;
}

.timeline-title {
  font-weight: 600;
  font-size: 13px;
  color: #1e293b;
}

.timeline-meta {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.timeline-comment {
  font-size: 13px;
  color: #4b5563;
  margin-top: 6px;
  font-style: italic;
}

/* ── Upload drop zone ── */
.upload-zone {
  border: 2px dashed #c7d2fe;
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: #fafafe;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: #ede9fe;
}

/* ── File upload thumbnail ── */
.upload-thumb-wrap {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.upload-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity .15s;
  border: 1px solid #e2e8f0;
}
.upload-thumb:hover { opacity: .8; }
.upload-doc-icon {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  transition: background .15s;
}
.upload-doc-icon:hover { background: #e2e8f0; }

/* ── Notifications dropdown ── */
.notif-dropdown {
  width: 340px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .12);
  overflow: hidden;
}

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  transition: background var(--transition);
}

.notif-item:hover {
  background: #f8fafc;
}

.notif-item.unread {
  background: #f0f4ff;
}

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notif-text .notif-title {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}

.notif-text .notif-msg {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

.notif-text .notif-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

/* ── Login page ── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #1e40af 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 44px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
}

.login-logo {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  margin: 0 auto 24px;
}

.login-title {
  text-align: center;
  margin-bottom: 8px;
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
}

.login-sub {
  text-align: center;
  color: #64748b;
  font-size: 14px;
  margin-bottom: 32px;
}

/* ── Sidebar Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .3);
  z-index: 999;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

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

/* ── Mobile Bottom Navigation — Premium Design ── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  /* Glass morphism */
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(226, 232, 240, .8);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, .08);
  /* Safe area for iPhone notch bottom */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-bottom-nav .nav-items {
  display: flex;
  height: 60px;
  align-items: stretch;
  justify-content: space-around;
  padding: 0 4px;
  position: relative;
}

/* Regular nav items */
.mobile-bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 600;
  padding: 6px 2px 4px;
  position: relative;
  border-radius: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color .2s ease;
  letter-spacing: 0.2px;
}

.mobile-bottom-nav .nav-item i {
  font-size: 22px;
  line-height: 1;
  transition: transform .2s ease, color .2s ease;
}

.mobile-bottom-nav .nav-item span {
  transition: color .2s ease;
  white-space: nowrap;
}

/* Active state */
.mobile-bottom-nav .nav-item.active {
  color: var(--primary);
}

.mobile-bottom-nav .nav-item.active i {
  transform: translateY(-1px);
}

/* Top indicator on active */
.mobile-bottom-nav .nav-item.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

/* ── FAB Center Button (แจ้งซ่อม) ── */
.mobile-bottom-nav .nav-item-fab {
  flex: 0 0 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  text-decoration: none;
  color: #64748b;
  font-size: 10px;
  font-weight: 600;
  padding-bottom: 5px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color .2s ease;
  letter-spacing: 0.2px;
}

.mobile-bottom-nav .nav-fab-btn {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(79, 70, 229, .45);
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  transition: transform .2s ease, box-shadow .2s ease;
  border: 3px solid #fff;
}

.mobile-bottom-nav .nav-item-fab:active .nav-fab-btn,
.mobile-bottom-nav .nav-item-fab.active .nav-fab-btn {
  transform: translateX(-50%) scale(.93);
  box-shadow: 0 2px 8px rgba(79, 70, 229, .35);
}

.mobile-bottom-nav .nav-item-fab span {
  margin-top: 36px;
  /* height to clear the FAB */
  transition: color .2s ease;
}

.mobile-bottom-nav .nav-item-fab.active {
  color: var(--primary);
}

/* Notification badge */
.mobile-bottom-nav .nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(239, 68, 68, .4);
}


/* ============================================================
   RESPONSIVE — Tablet (max-width: 991px)
   Sidebar hidden by default, toggled via hamburger
   ============================================================ */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }
}

/* ============================================================
   RESPONSIVE — Mobile + Tablet (max-width: 991px) shared
   ============================================================ */
@media (max-width: 991px) {
  .topbar {
    padding: 0 16px;
    gap: 12px;
  }

  .page-content {
    padding: 16px 16px 80px;
  }

  /* 80px bottom clearance for bottom-nav */
  .card-header {
    padding: 14px 16px 0;
    font-size: 14px;
  }

  .card-body {
    padding: 16px;
  }
}

/* ============================================================
   RESPONSIVE — Mobile only (max-width: 767px)
   ============================================================ */
@media (max-width: 767px) {

  /* Show mobile bottom nav */
  .mobile-bottom-nav {
    display: block;
  }

  /* Topbar adjustments */
  .topbar {
    height: 56px;
    padding: 0 12px;
    gap: 8px;
  }

  :root {
    --topbar-h: 56px;
  }

  .topbar-title {
    font-size: 15px;
    max-width: 160px;
  }

  /* Page header */
  .page-header {
    margin-bottom: 16px;
  }

  .page-header h1 {
    font-size: 18px;
  }

  .page-header.d-flex {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Page content */
  .page-content {
    padding: 12px 12px 80px;
  }

  /* Stat cards */
  .stat-card {
    padding: 14px;
    gap: 12px;
  }

  .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 18px;
    border-radius: 12px;
  }

  .stat-value {
    font-size: 22px;
  }

  .stat-label {
    font-size: 11px;
  }

  /* Cards */
  .card-header {
    padding: 12px 12px 0;
  }

  .card-body {
    padding: 12px;
  }

  .card {
    border-radius: 12px;
  }

  /* Forms: full-width grids on mobile */
  .row.g-3>[class*="col-md-"],
  .row.g-4>[class*="col-lg-"],
  .row.g-3>[class*="col-md"],
  .form-row>[class*="col-md"] {
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  /* Keep col-6 for 2-column grids (e.g., stat cards) */
  .row>.col-6 {
    width: 50%;
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* Buttons */
  .btn {
    font-size: 13px;
    padding: 8px 14px;
  }

  .btn-sm {
    font-size: 12px;
    padding: 5px 10px;
  }

  /* Status badges - smaller on mobile */
  .status-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    gap: 4px;
  }

  .status-badge::before {
    font-size: 0.9rem;
  }

  /* Notification dropdown full width */
  .notif-dropdown {
    width: calc(100vw - 24px);
  }

  /* Upload zone */
  .upload-zone {
    padding: 18px 12px;
  }

  .upload-zone .fs-2 {
    font-size: 1.5rem !important;
  }

  /* Login card */
  .login-card {
    padding: 28px 20px;
    border-radius: 16px;
  }

  .login-title {
    font-size: 20px;
  }

  /* Timeline: smaller on mobile */
  .timeline {
    padding-left: 20px;
  }

  .timeline-dot {
    left: -20px;
    width: 16px;
    height: 16px;
  }

  .timeline-body {
    padding: 10px 12px;
  }

  .timeline-title {
    font-size: 12px;
  }

  /* Modals: make them scrollable and centered, nearly full-screen on xs */
  .modal-dialog {
    margin: 12px auto;
    max-width: calc(100vw - 24px);
  }

  .modal-dialog.modal-lg {
    max-width: calc(100vw - 24px);
  }

  .modal-content {
    border-radius: 16px !important;
  }

  .modal-body {
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Pagination */
  .pagination {
    flex-wrap: wrap;
    gap: 4px;
  }

  .page-link {
    padding: 5px 10px;
    font-size: 13px;
  }

  /* Table responsive helper: full-width on mobile */
  .table-responsive {
    border-radius: 0;
  }
}

/* ============================================================
   RESPONSIVE — Extra-small phones (max-width: 400px)
   ============================================================ */
@media (max-width: 400px) {
  .page-header h1 {
    font-size: 16px;
  }

  .stat-value {
    font-size: 18px;
  }

  .topbar-title {
    display: none;
  }

  /* Show only icon on very small screens */
  .btn {
    font-size: 12px;
    padding: 7px 12px;
  }

  .stat-card {
    gap: 8px;
    padding: 12px 10px;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .mobile-bottom-nav .nav-item {
    font-size: 9px;
  }

  .mobile-bottom-nav .nav-item i {
    font-size: 18px;
  }
}

/* ============================================================
   Sidebar overlay — desktop: not displayed
   ============================================================ */
@media (min-width: 992px) {
  .sidebar-overlay {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: none !important;
  }

  /* Ensure proper padding on desktop (no bottom nav) */
  .page-content {
    padding-bottom: 28px;
  }
}

/* ============================================================
   Utilities
   ============================================================ */
.text-muted {
  color: #94a3b8 !important;
}

.fw-600 {
  font-weight: 600;
}

.fw-700 {
  font-weight: 700;
}

.gap-2 {
  gap: 8px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 14px;
}

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .w-md-auto {
    width: auto !important;
  }
}

/* Animate in */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp .35s ease forwards;
}

.delay-1 {
  animation-delay: .05s;
}

.delay-2 {
  animation-delay: .1s;
}

.delay-3 {
  animation-delay: .15s;
}

.delay-4 {
  animation-delay: .2s;
}

/* Print: hide sidebar, bottom nav, topbar */
@media print {

  .sidebar,
  .topbar,
  .mobile-bottom-nav,
  .sidebar-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-content {
    padding: 0 !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }
}

/* ─── Camera button: touch devices only ──────────────────────── */
.camera-only { display: none; }
@media (pointer: coarse), (hover: none) {
    .camera-only { display: inline-flex; align-items: center; justify-content: center; }
}