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

:root {
  --blue: #4285F4;
  --red: #EA4335;
  --yellow: #FBBC05;
  --green: #34A853;
  --dark: #202124;
  --gray-100: #f5f6f8;
  --gray-200: #e8eaed;
  --gray-400: #9aa0a6;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Mali', sans-serif;
  background: var(--gray-100);
  color: var(--dark);
  font-size: 18px;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 700; margin: 0 0 .5em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.3rem; }

/* ---------- Layout ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: #fff;
  box-shadow: var(--shadow);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.3rem;
  font-weight: 700;
}

.brand .dot { display:inline-flex; gap:4px; }
.brand .dot span { width: 12px; height: 12px; border-radius: 50%; display:inline-block; }
.brand .dot span:nth-child(1){ background: var(--blue); }
.brand .dot span:nth-child(2){ background: var(--red); }
.brand .dot span:nth-child(3){ background: var(--yellow); }
.brand .dot span:nth-child(4){ background: var(--green); }

.topbar nav { display: flex; gap: 8px; flex-wrap: wrap; align-items:center; }

.topbar .user-chip {
  background: var(--gray-100);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: .95rem;
}

.container {
  width: 80%;
  margin: 0 auto;
  padding: 28px 0 60px;
  flex: 1;
}

.footer {
  text-align: center;
  padding: 18px;
  color: var(--gray-400);
  font-size: .9rem;
}

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 22px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 20px;
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  box-shadow: var(--shadow);
}
.stat-card .num { font-size: 2.2rem; font-weight: 700; }
.stat-card .label { font-size: 1rem; opacity: .95; }
.bg-blue { background: var(--blue); }
.bg-red { background: var(--red); }
.bg-yellow { background: var(--yellow); color: var(--dark); }
.bg-green { background: var(--green); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform .05s ease, filter .15s ease;
  color: #fff;
  text-decoration: none;
}
.btn:hover { filter: brightness(0.92); text-decoration: none; }
.btn:active { transform: scale(.97); }

.btn-blue { background: var(--blue); }
.btn-red { background: var(--red); }
.btn-yellow { background: var(--yellow); color: var(--dark); }
.btn-green { background: var(--green); }
.btn-outline { background: #fff; color: var(--dark); border: 2px solid var(--gray-200); }
.btn-sm { padding: 8px 16px; font-size: .95rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
label { font-weight: 600; display: block; margin-bottom: 6px; }
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

input[type=text], input[type=password], input[type=date], input[type=number],
input[type=email], input[type=file], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  padding: 12px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  background: #fff;
  color: var(--dark);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
}
.hint { color: var(--gray-400); font-size: .9rem; margin-top: 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--gray-200); }
th { background: var(--gray-100); font-weight: 700; white-space: nowrap; }
tr:hover td { background: #fafbff; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.badge-blue { background: var(--blue); }
.badge-red { background: var(--red); }
.badge-yellow { background: var(--yellow); color: var(--dark); }
.badge-green { background: var(--green); }
.badge-gray { background: var(--gray-400); }

/* ---------- Alerts / Flash ---------- */
.alert {
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-weight: 600;
}
.alert-success { background: #e6f4ea; color: #1e7e34; border: 2px solid var(--green); }
.alert-error { background: #fce8e6; color: #a52714; border: 2px solid var(--red); }
.alert-info { background: #e8f0fe; color: #174ea6; border: 2px solid var(--blue); }
.alert-warning { background: #fef7e0; color: #7a5b00; border: 2px solid var(--yellow); }

/* ---------- Login pages ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--blue), var(--green));
}
.login-card {
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  padding: 40px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}
.login-card .dot { justify-content: center; margin-bottom: 10px; }
.login-choice {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  max-width: 640px;
  width: 100%;
}
.choice-card {
  background: #fff;
  border-radius: 20px;
  padding: 30px 20px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.15);
  transition: transform .15s ease;
}
.choice-card:hover { transform: translateY(-4px); text-decoration: none; }
.choice-card .icon { font-size: 2.6rem; margin-bottom: 10px; }

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.small { font-size: .9rem; color: var(--gray-400); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .container { width: 90%; padding: 18px 0 50px; }
  .card { padding: 18px; }
}

/* ---------- SweetAlert2 ---------- */
.swal-mali, .swal-mali * { font-family: 'Mali', sans-serif !important; }
.swal-mali.swal2-popup { border-radius: 20px; }
.swal-mali .swal2-confirm, .swal-mali .swal2-cancel {
  border-radius: 999px !important;
  font-weight: 600 !important;
  padding: 10px 22px !important;
}

/* ---------- โลโก้โรงเรียน ---------- */
.brand-logo {
  height: 44px !important;
  width: 44px !important;
  max-height: 44px !important;
  max-width: 44px !important;
  object-fit: contain;
  border-radius: 50%;
  flex-shrink: 0;
}
.login-logo {
  display: block;
  height: 90px !important;
  width: 90px !important;
  max-height: 100px !important;
  max-width: 100px !important;
  object-fit: contain;
  margin: 0 auto 14px;
  border-radius: 50%;
}

/* ---------- หน้าล็อกอินแบบ 2 คอลัมน์ (60/40) ---------- */
.login-split-card {
  display: flex;
  align-items: stretch;
  max-width: 980px;
  width: 100%;
  margin: 30px auto;
  padding: 0;
  overflow: hidden;
}
.login-split-col { padding: 32px; }
.login-split-left {
  flex: 0 0 60%;
  max-width: 60%;
  border-right: 2px solid var(--gray-200);
}
.login-split-right {
  flex: 0 0 40%;
  max-width: 40%;
}
@media (max-width: 768px) {
  .login-split-card { flex-direction: column; }
  .login-split-left, .login-split-right {
    flex: 1 1 100%;
    max-width: 100%;
  }
  .login-split-left { border-right: none; border-bottom: 2px solid var(--gray-200); }
}

/* ---------- แท็บสลับล็อกอิน นักเรียน/ครู ---------- */
.login-tabs {
  display: flex;
  gap: 6px;
  background: var(--gray-100);
  padding: 6px;
  border-radius: 999px;
  margin: 16px 0 20px;
}
.login-tab {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.login-tab.active { background: var(--blue); color: #fff; }
.login-tab-panel { text-align: left; }
