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

/* ---------- Enhanced Site CSS ---------- */
body {
  font-family: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(120% 120% at 10% 20%, rgba(99, 102, 241, 0.08), transparent),
    radial-gradient(120% 120% at 90% 10%, rgba(236, 72, 153, 0.08), transparent),
    var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* ========== Enhanced Header ========== */
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: var(--space-5) var(--space-6);
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

header h2 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

header div {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

header nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

header nav a {
  color: rgba(255, 255, 255, 0.9);
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

header nav a:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========== Main Content ========== */
main {
  max-width: 1200px;
  margin: 24px auto 40px;
  padding: 0 var(--space-4);
}

.wrap,
.section {
  max-width: 1200px;
  margin: 24px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--space-6);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.admin-body main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--space-6);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--space-4);
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

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

.muted {
  color: var(--text-muted);
  padding: 12px 16px;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 8px;
  border-left: 4px solid #22c55e;
  margin: 12px 0;
}

.mt {
  margin-top: var(--space-3);
}

/* ========== Form Elements ========== */
label,
.label {
  display: block;
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  padding: 12px 16px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

/* ========== Enhanced Buttons ========== */
button,
.btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  text-decoration: none;
  transition: all 0.3s ease;
  font-weight: 600;
}

button:hover,
.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

button:active,
.btn:active {
  transform: translateY(-1px);
}

button:disabled,
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

a.btn {
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.btn-success:hover {
  box-shadow: 0 8px 25px rgba(34, 197, 94, 0.5);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-3);
}

/* ========== Alerts ========== */
.alert {
  padding: 16px 20px;
  border-radius: 12px;
  border: none;
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert::before {
  font-size: 1.25rem;
}

.alert-ok {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.alert-ok::before {
  content: '✓';
}

.alert-error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.alert-error::before {
  content: '✕';
}

.alert-warn {
  background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
}

.alert-warn::before {
  content: '⚠';
}

.err {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  padding: var(--space-4);
  border-radius: 12px;
  margin-bottom: var(--space-4);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

/* ========== Enhanced Table ========== */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  color: var(--text);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

tbody tr {
  transition: all 0.2s ease;
}

tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

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

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 20px;
  font-weight: 600;
  gap: 4px;
}

.badge-remaining {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.25));
  color: #16a34a;
}

.badge-full {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.25));
  color: #dc2626;
}

/* ========== Calendar ========== */
.fc-title {
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

.fc-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
}

#calendar {
  margin-top: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--space-5);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.fc .fc-toolbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.fc .fc-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  transition: all 0.2s ease;
}

.fc .fc-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.fc .fc-button:disabled {
  background: var(--border);
  color: var(--text-muted);
  box-shadow: none;
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
  border: none;
}

.fc .fc-col-header-cell {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 12px 0;
  color: var(--text-muted);
}

.fc .fc-daygrid-day {
  background: var(--surface);
  transition: all 0.2s ease;
}

.fc .fc-daygrid-day:hover {
  background: rgba(99, 102, 241, 0.04);
}

.fc .fc-daygrid-day-number {
  color: var(--text-muted);
  font-weight: 600;
}

.fc .fc-daygrid-event {
  border-radius: 6px;
  padding: 6px 8px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fc .fc-list-day-cushion {
  background: var(--bg-alt);
}

/* ========== Details/Summary ========== */
details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface);
  transition: all 0.2s ease;
}

details:hover {
  border-color: var(--primary);
}

details[open] {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

summary:hover {
  background: rgba(99, 102, 241, 0.08);
}

/* ========== Footer ========== */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 20px 0 40px;
}

p.inline-note {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: var(--space-2);
}

/* ========== Login Box ========== */
.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: var(--space-8);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08);
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-4);
  background:
    linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15)),
    var(--bg);
}

.login-body .box {
  width: min(420px, 92%);
}

.main-note {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: var(--space-3);
}

code {
  background: var(--bg-alt);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: 'Fira Code', monospace;
}

/* ========== Heading Styles ========== */
h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--space-4);
  display: flex;
  align-items: center;
  gap: 10px;
}

h2::before {
  content: '';
  width: 4px;
  height: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 2px;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: var(--space-6) 0 var(--space-3);
}

/* ========== Responsive ========== */
@media (max-width: 720px) {
  header {
    padding: var(--space-5) var(--space-4);
  }

  header h2 {
    font-size: 1.3rem;
  }

  header nav {
    gap: 6px;
  }

  header nav a {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  main {
    padding: 0 var(--space-3);
    margin: 16px auto 32px;
  }

  .wrap,
  .section,
  .admin-body main {
    padding: var(--space-5);
    border-radius: 12px;
  }

  table {
    font-size: 0.9rem;
  }

  th,
  td {
    padding: 10px 12px;
  }

  button,
  .btn {
    padding: 10px 18px;
    font-size: 0.9rem;
  }
}

/* ========== Animation ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

main {
  animation: fadeIn 0.3s ease-out;
}

table tbody tr {
  animation: fadeIn 0.3s ease-out backwards;
}

table tbody tr:nth-child(1) {
  animation-delay: 0.05s;
}

table tbody tr:nth-child(2) {
  animation-delay: 0.1s;
}

table tbody tr:nth-child(3) {
  animation-delay: 0.15s;
}

table tbody tr:nth-child(4) {
  animation-delay: 0.2s;
}

table tbody tr:nth-child(5) {
  animation-delay: 0.25s;
}