/* Modern Commercial SaaS OMR Design System */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #7c3aed;
  --secondary-hover: #6d28d9;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --dark-bg: #0f172a;
  --card-bg: rgba(255, 255, 255, 0.95);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.06);
}

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

body {
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  background: #f8fafc;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.2s;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s ease;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.35rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-logo span.badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  -webkit-text-fill-color: var(--primary);
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 1.8rem;
  align-items: center;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  font-weight: 500;
}
.nav-links a:hover {
  color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.65rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-success {
  background: var(--success);
  color: white;
}

/* Landing Page Hero */
.hero-section {
  position: relative;
  overflow: hidden;
  padding: 5rem 2rem 6rem;
  text-align: center;
  background: radial-gradient(circle at 50% 10%, rgba(37, 99, 235, 0.08) 0%, transparent 60%);
}

.hero-tag {
  display: inline-block;
  padding: 6px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--primary);
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.hero-title {
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1.25;
  margin-bottom: 1.5rem;
  letter-spacing: -0.5px;
}

.hero-title .gradient-text {
  background: linear-gradient(135deg, #1e40af, #7c3aed, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.25rem;
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 auto 2.5rem;
}

.hero-cta-group {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 3.5rem;
}

/* App Mockup / Visual Hero */
.hero-preview-container {
  max-width: 1000px;
  margin: 0 auto;
  border-radius: 16px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,0.7), rgba(255,255,255,0.3));
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 20px 40px -15px rgba(0,0,0,0.15);
}

.hero-preview-box {
  background: #1e293b;
  border-radius: 12px;
  padding: 2.5rem;
  color: white;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 2rem;
  align-items: center;
  text-align: left;
}

.preview-features li {
  list-style: none;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
}
.preview-features li span.icon {
  color: var(--success);
  font-weight: bold;
}

/* Feature Grid */
.section {
  padding: 5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.section-header {
  text-align: center;
  margin-bottom: 3.5rem;
}
.section-title {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.8rem;
}
.section-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
}

.feature-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #cbd5e1;
}

.feature-icon {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  margin-bottom: 1.25rem;
}

.feature-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.feature-card p {
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.6;
}

/* Pricing / Plan Table */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.pricing-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.pricing-card.featured {
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-lg);
  transform: scale(1.03);
}

.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.plan-name {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.plan-quota {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--primary);
  margin: 1rem 0;
}
.plan-quota span {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}
.plan-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.plan-items {
  text-align: left;
  margin: 1.5rem 0 2rem;
  list-style: none;
  font-size: 0.95rem;
}
.plan-items li {
  margin-bottom: 10px;
  display: flex;
  gap: 8px;
  color: #334155;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-backdrop.show {
  display: flex;
}

.modal-card {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 440px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalFadeIn 0.25s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-close {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  font-size: 1.5rem;
  color: #94a3b8;
  background: none;
}
.modal-close:hover {
  color: var(--text-main);
}

.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: #334155;
}
.form-input, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s;
}
.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  outline: none;
}

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

.sidebar {
  width: 260px;
  background: #0f172a;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 800;
  color: white;
}

.sidebar-user {
  padding: 1.25rem;
  border-bottom: 1px solid #1e293b;
  background: #1e293b;
}
.user-name {
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
}
.user-school {
  font-size: 0.8rem;
  color: #94a3b8;
}
.quota-box {
  margin-top: 10px;
  background: #0f172a;
  border-radius: 6px;
  padding: 8px;
  font-size: 0.8rem;
}
.quota-progress {
  height: 6px;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.quota-progress-bar {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

.sidebar-menu {
  padding: 1rem 0;
  list-style: none;
  flex: 1;
}
.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.8rem 1.25rem;
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.95rem;
}
.sidebar-menu li a:hover, .sidebar-menu li.active a {
  color: white;
  background: #1e293b;
  border-left: 4px solid var(--primary);
}

.main-content {
  flex: 1;
  background: #f8fafc;
  overflow-y: auto;
  padding: 2rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}
.page-title {
  font-size: 1.8rem;
  font-weight: 800;
}

/* Scanner Viewport */
.camera-viewport {
  position: relative;
  width: 100%;
  max-width: 600px;
  height: 480px;
  margin: 0 auto;
  background: black;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-overlay {
  position: absolute;
  inset: 15px;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-overlay::after {
  content: 'เล็งกระดาษคำตอบให้อยู่ในกรอบ 4 มุม';
  color: white;
  background: rgba(0, 0, 0, 0.6);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
}

/* Mobile Responsive */
@media (max-width: 900px) {
  .hero-title { font-size: 2.3rem; }
  .hero-preview-box { grid-template-columns: 1fr; }
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; }
}

/* =============================================================
   TOAST NOTIFICATIONS (Floating Top-Right, Auto-Fade)
   ============================================================= */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 440px;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: #ffffff;
  font-family: 'Sarabun', sans-serif;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  backdrop-filter: blur(8px);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.hide {
  transform: translateX(120%);
  opacity: 0;
}

.toast-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.88rem;
  line-height: 1.4;
  opacity: 0.95;
  word-break: break-word;
}

.toast-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  margin-left: 4px;
}
.toast-close:hover {
  color: #ffffff;
}

.toast-success {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  border-left: 5px solid #34d399;
}

.toast-error {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  border-left: 5px solid #f87171;
}

.toast-warning {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  border-left: 5px solid #fbbf24;
}

.toast-info {
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  border-left: 5px solid #60a5fa;
}

/* =============================================================
   INSPECTION STUDIO PREVIEW (run.py Style)
   ============================================================= */
.inspection-studio-container {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 992px) {
  .inspection-studio-container {
    grid-template-columns: 1fr;
  }
}

.inspection-canvas-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inspection-canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: #94a3b8;
  font-size: 0.85rem;
  padding-bottom: 8px;
  border-bottom: 1px solid #1e293b;
}

.inspection-image-viewport {
  overflow: auto;
  max-height: 680px;
  border-radius: 8px;
  background: #1e293b;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10px;
}

.inspection-image-viewport img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  transition: transform 0.2s ease;
}

.inspection-details-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.inspect-badge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inspect-badge-id {
  background: #eff6ff;
  border: 2px solid #3b82f6;
  border-radius: 10px;
  padding: 12px 14px;
}

.inspect-badge-id .lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: #3b82f6;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.inspect-badge-id .val {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e3a8a;
  margin-top: 2px;
}

.inspect-badge-set {
  background: #fffbeb;
  border: 2px solid #f59e0b;
  border-radius: 10px;
  padding: 12px 14px;
}

.inspect-badge-set .lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: #d97706;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.inspect-badge-set .val {
  font-size: 1.5rem;
  font-weight: 800;
  color: #92400e;
  margin-top: 2px;
}

.inspect-badge-score {
  background: #f0fdf4;
  border: 2px solid #22c55e;
  border-radius: 10px;
  padding: 14px 18px;
  text-align: center;
}

.inspect-badge-score .lbl {
  font-size: 0.85rem;
  font-weight: 700;
  color: #16a34a;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.inspect-badge-score .val {
  font-size: 2.4rem;
  font-weight: 900;
  color: #15803d;
  margin: 2px 0;
}

.inspect-badge-score .pct {
  font-size: 1rem;
  font-weight: 600;
  color: #166534;
}

.inspect-terminal-box {
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  color: #e2e8f0;
  max-height: 320px;
  overflow-y: auto;
}

.inspect-terminal-box .terminal-title {
  color: #94a3b8;
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 8px;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.inspect-terminal-box .wrong-item {
  color: #f87171;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.inspect-terminal-box .perfect-item {
  color: #4ade80;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
  padding: 1rem 0;
}


