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

:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary-color: #475569;
  --accent-color: #0d9488;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Sarabun', 'Prompt', sans-serif;
}

body {
  background-color: #f8fafc;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navbar */
.app-navbar {
  background: #1e293b;
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.brand-title {
  font-family: 'Prompt', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
}

.user-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.role-tag {
  background: var(--primary-color);
  color: white;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
}

.btn-logout {
  background: #dc2626;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #b91c1c;
}

/* Layout */
.app-container {
  display: flex;
  flex: 1;
}

.app-sidebar {
  width: 260px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--secondary-color);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-item:hover {
  background: #f1f5f9;
  color: var(--primary-color);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-color);
  font-weight: 600;
}

.nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
}

.app-content {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

/* Cards & Stats */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.card-title {
  font-family: 'Prompt', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.stat-val {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  font-family: 'Prompt', sans-serif;
}

.stat-lbl {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  color: var(--secondary-color);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid #e2e8f0;
  white-space: nowrap;
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
}

.data-table tr:hover {
  background-color: #f8fafc;
}

.input-score {
  width: 54px;
  padding: 4px 6px;
  text-align: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.88rem;
}

.input-score:focus {
  outline: 2px solid var(--primary-color);
  border-color: transparent;
}

/* Badges & Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

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

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

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

.btn-success:hover {
  background: #059669;
}

.btn-outline {
  background: white;
  border: 1px solid var(--border-color);
  color: var(--secondary-color);
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-4 { background: #dcfce7; color: #15803d; }
.badge-3 { background: #e0f2fe; color: #0369a1; }
.badge-2 { background: #fef3c7; color: #b45309; }
.badge-1 { background: #ffedd5; color: #c2410c; }
.badge-0 { background: #fee2e2; color: #b91c1c; }

/* Login Modal */
.login-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-box {
  background: white;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--secondary-color);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
}

.form-input:focus {
  outline: 2px solid var(--primary-color);
}

/* Print CSS for ปพ.1 and ปพ.6 */
@media print {
  body {
    background: white;
    color: black;
  }
  .app-navbar, .app-sidebar, .btn, .no-print {
    display: none !important;
  }
  .app-content {
    padding: 0 !important;
    overflow: visible !important;
  }
  .card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }
  .print-page {
    page-break-after: always;
    padding: 15mm;
  }
}
