/* assets/css/app.css */
:root {
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --primary: #1a56db;
  --primary-light: #e8f0fe;
  --primary-dark: #1239a0;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1a56db;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --font: 'Plus Jakarta Sans', sans-serif;
  --font-display: 'Syne', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}

.brand-icon {
  width: 44px; height: 44px;
  background: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  display: block;
  line-height: 1.2;
  letter-spacing: -.3px;
}

.brand-sub {
  font-size: 10px;
  color: var(--sidebar-text);
  opacity: .7;
  display: block;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.3);
  padding: 20px 20px 6px;
}

.sidebar-nav {
  list-style: none;
  padding: 0 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
}

.sidebar-link i { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

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

.sidebar-footer {
  margin-top: auto;
  padding: 16px 10px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,.05);
  border-radius: 8px;
  margin-bottom: 4px;
}

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

.user-name { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.3; }
.user-role { font-size: 11px; color: rgba(255,255,255,.4); }

.logout-link { color: #f87171 !important; }
.logout-link:hover { background: rgba(239,68,68,.15) !important; color: #fca5a5 !important; }

/* ========== MAIN WRAPPER ========== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s cubic-bezier(.4,0,.2,1);
}

/* ========== TOPBAR ========== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.3px;
}

.sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--text); }
.sidebar-toggle i { width: 18px; height: 18px; }

/* ========== CONTENT AREA ========== */
.content-area {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

/* ========== CARDS ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  background: none;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header i { width: 18px; height: 18px; color: var(--primary); }
.card-body { padding: 20px; }

/* ========== STAT CARDS ========== */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .2s;
}

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

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon i { width: 24px; height: 24px; }
.stat-icon.blue { background: #eff6ff; color: #1d4ed8; }
.stat-icon.green { background: #f0fdf4; color: #15803d; }
.stat-icon.amber { background: #fffbeb; color: #b45309; }
.stat-icon.purple { background: #faf5ff; color: #7e22ce; }

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  letter-spacing: -1px;
}

.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* ========== TABLES ========== */
.table-responsive { border-radius: var(--radius); overflow: hidden; }

.table {
  margin: 0;
  font-size: 13.5px;
}

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

.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody td { padding: 12px 16px; border-color: #f1f5f9; vertical-align: middle; }

/* ========== FORMS ========== */
.form-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 5px;
}

.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  padding: 9px 13px;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-control.is-invalid { border-color: var(--danger); }

/* ========== BUTTONS ========== */
.btn {
  font-family: var(--font);
  font-weight: 600;
  border-radius: 8px;
  font-size: 13.5px;
  transition: all .15s;
}

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

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}

.btn-icon i { width: 15px; height: 15px; }

/* ========== BADGES ========== */
.badge {
  font-family: var(--font);
  font-weight: 600;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
}

/* ========== SECTION CARD (Inspection Form) ========== */
.section-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}

.section-card-header {
  background: linear-gradient(135deg, #1a56db 0%, #1239a0 100%);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-display);
}

.section-number {
  width: 26px; height: 26px;
  background: rgba(255,255,255,.2);
  border-radius: 6px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.question-row {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  gap: 16px;
}

.question-row:last-child { border-bottom: none; }
.question-row:nth-child(even) { background: #fafbfc; }

.question-label {
  flex: 0 0 45%;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  padding-top: 3px;
}

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

.question-answer { flex: 1; }

.answer-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-option-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  transition: all .15s;
  user-select: none;
}

.answer-option-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

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

.answer-option-btn input { display: none; }

/* ========== DRAG HANDLE ========== */
.drag-handle {
  cursor: grab;
  color: var(--text-light);
  padding: 4px;
  display: inline-flex;
  align-items: center;
}
.drag-handle:active { cursor: grabbing; }

.sortable-ghost { opacity: .4; background: var(--primary-light) !important; }
.sortable-chosen { background: var(--primary-light) !important; }

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

.page-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.4px;
  line-height: 1.2;
}

.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ========== SEARCH BAR ========== */
.search-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

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

.search-input-wrap i {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

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

/* ========== INSPECTION STATUS ========== */
.status-draft { background: #fef3c7; color: #92400e; }
.status-completed { background: #d1fae5; color: #065f46; }

/* ========== OVERLAY ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.visible {
    display: block;
  }
  .main-wrapper {
    margin-left: 0;
  }
  .content-area {
    padding: 16px;
  }
  .question-row {
    flex-direction: column;
    gap: 8px;
  }
  .question-label { flex: none; }
  .answer-options { gap: 6px; }
  .answer-option-btn { font-size: 12px; padding: 6px 12px; }
  .stat-value { font-size: 22px; }
}

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

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,.3);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand-icon {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 18px;
  display: inline-flex;
  align-items: center; justify-content: center;
  margin-bottom: 16px;
  color: #fff;
}

.login-brand h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.5px;
}

.login-brand p { color: var(--text-muted); font-size: 13px; }

/* ========== PRINT / PDF styles ========== */
@media print { .sidebar, .topbar, .sidebar-overlay { display: none !important; } .main-wrapper { margin: 0 !important; } }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { width: 48px; height: 48px; opacity: .4; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* Tooltip */
[data-bs-toggle="tooltip"] { cursor: pointer; }

/* Smooth scroll */
html { scroll-behavior: smooth; }

/* Photo preview */
.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.photo-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--border);
}

.photo-preview-item img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.photo-remove-btn {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(239,68,68,.9);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
