/* AuditPro - Supplier Audit Management System */
/* Main App CSS */

:root {
  --primary: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-dark: #1e40af;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
}

.app-container { min-height: 100vh; }

/* NAV */
.navbar {
  background: var(--primary);
  color: white;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-logo { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.nav-links { display: flex; gap: 0.5rem; align-items: center; }
.nav-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s;
}
.nav-btn:hover { background: rgba(255,255,255,0.25); }
.nav-btn.active { background: rgba(255,255,255,0.3); }

/* PAGE LAYOUTS */
.page { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }
.page-header { margin-bottom: 1.5rem; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text); margin: 0 0 0.25rem; }
.page-subtitle { color: var(--muted); font-size: 0.9rem; }

/* CARDS */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card-header { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.4rem; }

/* PROGRESS / SCORES */
.score-bar-wrap { background: #e2e8f0; border-radius: 99px; height: 10px; overflow: hidden; }
.score-bar { height: 100%; border-radius: 99px; transition: width 0.5s ease; }
.score-pass { background: var(--success); }
.score-warn { background: var(--warning); }
.score-fail { background: var(--danger); }

/* RAG STATUS */
.rag-red { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; border-radius: 6px; padding: 2px 10px; font-size: 0.8rem; font-weight: 600; }
.rag-amber { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; border-radius: 6px; padding: 2px 10px; font-size: 0.8rem; font-weight: 600; }
.rag-green { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; border-radius: 6px; padding: 2px 10px; font-size: 0.8rem; font-weight: 600; }
.rag-na { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; border-radius: 6px; padding: 2px 10px; font-size: 0.8rem; font-weight: 600; }
.rag-pending { background: #f8fafc; color: #94a3b8; border: 1px solid #e2e8f0; border-radius: 6px; padding: 2px 10px; font-size: 0.8rem; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1f5f9; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-xs { padding: 3px 8px; font-size: 0.75rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text); margin-bottom: 0.4rem; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: white;
  color: var(--text);
  transition: border-color 0.2s;
  outline: none;
}
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* CHECKLIST */
.question-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  background: white;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.question-card:hover { border-color: #93c5fd; box-shadow: 0 2px 8px rgba(59,130,246,0.08); }
.question-card.answered-green { border-left: 4px solid var(--success); }
.question-card.answered-amber { border-left: 4px solid var(--warning); }
.question-card.answered-red { border-left: 4px solid var(--danger); }
.question-card.answered-na { border-left: 4px solid #94a3b8; }

.question-number { background: var(--primary); color: white; border-radius: 6px; padding: 2px 8px; font-size: 0.75rem; font-weight: 700; }
.question-text { font-weight: 500; font-size: 0.95rem; margin: 0.5rem 0; line-height: 1.5; }

.score-selector { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.score-btn {
  width: 44px; height: 44px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: white;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.score-btn:hover { border-color: var(--primary); color: var(--primary); transform: scale(1.05); }
.score-btn.active-0 { background: #fee2e2; border-color: #dc2626; color: #dc2626; }
.score-btn.active-1 { background: #fee2e2; border-color: #dc2626; color: #dc2626; }
.score-btn.active-2 { background: #ffedd5; border-color: #f97316; color: #ea580c; }
.score-btn.active-3 { background: #fef9c3; border-color: #ca8a04; color: #92400e; }
.score-btn.active-4 { background: #dcfce7; border-color: #16a34a; color: #15803d; }
.score-btn.active-5 { background: #dcfce7; border-color: #16a34a; color: #15803d; }
.score-btn.active-na { background: #f1f5f9; border-color: #94a3b8; color: #64748b; width: auto; padding: 0 10px; font-size: 0.8rem; }

/* COLLAPSIBLE */
.collapsible-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  padding: 0.75rem 0;
  user-select: none;
}
.collapsible-header:hover { color: var(--primary); }
.collapse-icon { transition: transform 0.2s; }
.collapse-icon.open { transform: rotate(180deg); }

/* SECTION TABS */
.section-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  height: fit-content;
  position: sticky;
  top: 70px;
}
.section-tab {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.82rem;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.section-tab:hover { background: #f8fafc; }
.section-tab.active { background: #eff6ff; border-left: 3px solid var(--primary); color: var(--primary); font-weight: 600; }
.section-progress { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(2px);
}
.modal {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.5rem; }

/* AUDIT SELECTION */
.oem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.oem-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}
.oem-card:hover { border-color: var(--primary-light); box-shadow: 0 4px 12px rgba(59,130,246,0.15); transform: translateY(-2px); }
.oem-card.selected { border-color: var(--primary); background: #eff6ff; }
.oem-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.oem-name { font-weight: 600; font-size: 0.9rem; }
.oem-code { font-size: 0.75rem; color: var(--muted); }

/* AUTH PAGE */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 40%, #2563eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-card {
  background: white;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo h1 { font-size: 2rem; font-weight: 800; color: var(--primary); }
.auth-logo p { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

.otp-inputs { display: flex; gap: 0.5rem; justify-content: center; margin: 1rem 0; }
.otp-digit {
  width: 52px; height: 60px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.otp-digit:focus { border-color: var(--primary); }

/* TABLE */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { background: #f8fafc; padding: 10px 14px; text-align: left; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--border); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.data-table tr:hover td { background: #f8fafc; }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 1rem; font-size: 0.875rem; display: flex; align-items: flex-start; gap: 0.5rem; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* TOOLTIP */
.info-btn {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #dbeafe;
  color: #2563eb;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: background 0.2s;
  flex-shrink: 0;
}
.info-btn:hover { background: #bfdbfe; }

/* DROPDOWN */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 180px;
  z-index: 200;
  display: none;
  overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-item { padding: 10px 16px; cursor: pointer; font-size: 0.875rem; transition: background 0.15s; display: flex; align-items: center; gap: 0.5rem; }
.dropdown-item:hover { background: #f8fafc; }

/* BADGE */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-yellow { background: #fef9c3; color: #92400e; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-gray { background: #f1f5f9; color: #64748b; }

/* ATTACHMENT */
.attachment-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.attachment-item {
  display: flex; align-items: center; gap: 0.4rem;
  background: #f1f5f9; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-size: 0.8rem; cursor: pointer;
}
.attachment-item:hover { background: #e2e8f0; }

/* TABS */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* DASHBOARD CIRCULAR */
.score-circle {
  width: 120px; height: 120px;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800;
  border: 6px solid;
}
.score-circle.pass { border-color: var(--success); color: var(--success); }
.score-circle.warn { border-color: var(--warning); color: var(--warning); }
.score-circle.fail { border-color: var(--danger); color: var(--danger); }

/* LOADING */
.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* QUESTION EXPAND PANEL */
.expand-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 0.75rem;
}
.expand-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.35rem; }
.expand-value { font-size: 0.875rem; color: var(--text); line-height: 1.6; white-space: pre-wrap; }

/* PRINT */
@media print {
  .navbar, .section-sidebar, .btn, .nav-links { display: none !important; }
  .page { padding: 0; max-width: 100%; }
  .question-card { page-break-inside: avoid; }
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .page { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .section-sidebar { width: 100%; position: static; }
  .checklist-layout { flex-direction: column !important; }
  .oem-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { padding: 1.5rem; }
}

/* AUDIT SUMMARY CARD */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.info-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 0.875rem; }
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--muted); font-weight: 500; flex-shrink: 0; }
.info-val { font-weight: 600; text-align: right; max-width: 60%; }

/* CUSTOMER AUDIT SECTION */
.customer-audit-card { background: linear-gradient(135deg, #fef3c7 0%, #fff9e6 100%); border: 1px solid #fbbf24; border-radius: 10px; padding: 1.5rem; }
