/* ============================================================
   ESPM — Sistem Pengurusan Sektor Pembangunan Murid
   Mobile-First CSS  |  Purple-Blue Theme
   ============================================================ */

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

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --primary:        #7C3AED;
  --primary-dark:   #5B21B6;
  --primary-light:  #EDE9FE;
  --secondary:      #2563EB;
  --secondary-light:#DBEAFE;
  --success:        #059669;
  --success-light:  #D1FAE5;
  --danger:         #DC2626;
  --danger-light:   #FEE2E2;
  --warning:        #D97706;
  --warning-light:  #FEF3C7;
  --info:           #0891B2;
  --info-light:     #CFFAFE;
  --dark:           #1E1B4B;
  --body-bg:        #F5F3FF;
  --card-bg:        #FFFFFF;
  --text-muted:     #6B7280;
  --border:         #E5E7EB;
  --nav-height:     68px;
  --header-height:  60px;
  --radius:         16px;
  --radius-sm:      10px;
  --shadow:         0 4px 20px rgba(124,58,237,.10);
  --shadow-card:    0 2px 12px rgba(0,0,0,.06);
  --gradient:       linear-gradient(135deg, #7C3AED 0%, #2563EB 100%);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--body-bg);
  color: var(--dark);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-height) + 12px);
}

/* ── App Wrapper (mobile-first centered) ───────────────────── */
.app-wrapper {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
  background: var(--body-bg);
}

/* ── Top Header ────────────────────────────────────────────── */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--gradient);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  box-shadow: 0 4px 20px rgba(124,58,237,.3);
}

.top-header .app-title {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.01em;
  line-height: 1.2;
}
.top-header .app-subtitle {
  color: rgba(255,255,255,.75);
  font-size: .7rem;
  font-weight: 400;
}

.top-header .btn-header {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background .2s;
  text-decoration: none;
}
.top-header .btn-header:hover { background: rgba(255,255,255,.35); }

/* ── Bottom Navigation ─────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  border-radius: 20px 20px 0 0;
}

.nav-item-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: .62rem;
  font-weight: 500;
  padding: 8px 4px;
  border-radius: 12px;
  transition: all .2s;
  position: relative;
}

.nav-item-btn i {
  font-size: 1.3rem;
  line-height: 1;
  transition: all .2s;
}

.nav-item-btn.active {
  color: var(--primary);
}
.nav-item-btn.active i {
  transform: translateY(-2px);
}
.nav-item-btn.active::before {
  content: '';
  position: absolute;
  top: 6px;
  width: 32px;
  height: 32px;
  background: var(--primary-light);
  border-radius: 10px;
  z-index: -1;
}

/* ── Hero Banner ───────────────────────────────────────────── */
.hero-banner {
  background: var(--gradient);
  padding: 20px 20px 40px;
  position: relative;
  overflow: hidden;
}
.hero-banner::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: 0; right: 0;
  height: 40px;
  background: var(--body-bg);
  border-radius: 50% 50% 0 0 / 40px 40px 0 0;
}
.hero-banner .greeting {
  color: rgba(255,255,255,.8);
  font-size: .8rem;
}
.hero-banner .hero-name {
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
}
.hero-banner .hero-date {
  color: rgba(255,255,255,.7);
  font-size: .75rem;
}
.hero-avatar {
  width: 46px; height: 46px;
  background: rgba(255,255,255,.25);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.4rem;
}

/* ── Stat Cards ────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 16px;
  margin-top: -16px;
  position: relative;
  z-index: 2;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: transform .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

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

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--dark);
}
.stat-label {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Section Headers ───────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}
.section-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title i {
  color: var(--primary);
}
.section-link {
  font-size: .75rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* ── Content Cards ─────────────────────────────────────────── */
.content-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  margin: 0 16px 12px;
  overflow: hidden;
}

.card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background .15s;
}
.card-item:last-child { border-bottom: none; }
.card-item:hover      { background: #F9FAFB; }

.card-item-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.card-item-body { flex: 1; min-width: 0; }
.card-item-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-item-sub {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Page Content ──────────────────────────────────────────── */
.page-content {
  padding: 16px;
  padding-top: 8px;
}

/* ── Form Styles ───────────────────────────────────────────── */
.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 4px;
}

.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  padding: 10px 14px;
  transition: border-color .2s, box-shadow .2s;
  background: var(--card-bg);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,.12);
  outline: none;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary-custom {
  background: var(--gradient);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-weight: 600;
  font-size: .9rem;
  width: 100%;
  transition: opacity .2s, transform .15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary-custom:hover { opacity: .9; transform: translateY(-1px); color:#fff; }
.btn-primary-custom:active { transform: translateY(0); }

.btn-outline-primary-custom {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 600;
  font-size: .85rem;
  transition: all .2s;
}
.btn-outline-primary-custom:hover { background: var(--primary); color: #fff; }

.btn-whatsapp {
  background: linear-gradient(135deg, #25D366, #128C7E);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 600;
  font-size: .85rem;
  display: flex; align-items: center; gap: 8px;
  transition: opacity .2s;
}
.btn-whatsapp:hover { opacity: .9; color: #fff; }

/* ── FAB Button ────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: calc(50% - 240px + 16px);
  width: 52px; height: 52px;
  background: var(--gradient);
  border: none;
  border-radius: 16px;
  color: #fff;
  font-size: 1.4rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(124,58,237,.4);
  z-index: 150;
  transition: transform .2s, box-shadow .2s;
  text-decoration: none;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(124,58,237,.5); color:#fff; }
@media (max-width: 480px) { .fab { right: 16px; } }

/* ── Avatar Circles ────────────────────────────────────────── */
.avatar {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

/* ── Staff List ────────────────────────────────────────────── */
.staff-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  transition: transform .2s;
}
.staff-card:hover { transform: translateX(4px); }

/* ── Movement List ─────────────────────────────────────────── */
.movement-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
}
.movement-card.category-cuti  { border-left-color: #059669; }
.movement-card.category-sakit { border-left-color: #D97706; }
.movement-card.category-rasmi { border-left-color: #2563EB; }
.movement-card.category-kecemasan { border-left-color: #DC2626; }

/* ── Payment Status ────────────────────────────────────────── */
.payment-badge-paid   { background: var(--success-light); color: var(--success); }
.payment-badge-unpaid { background: var(--danger-light);  color: var(--danger); }
.payment-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}

/* ── Checkbox selection for WhatsApp ───────────────────────── */
.select-check {
  width: 20px; height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Filter Bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 16px 12px;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}
.filter-chip.active, .filter-chip:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ── Birthday Card ─────────────────────────────────────────── */
.birthday-today {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  border: 1px solid #F59E0B;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
}

/* ── Login Page ────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  background: var(--gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 24px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.login-logo {
  width: 64px; height: 64px;
  background: var(--primary-light);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto 16px;
}

/* ── Calendar Page ─────────────────────────────────────────── */
#calendar { font-size: .82rem; }
.fc-toolbar-title { font-size: 1rem !important; font-weight: 700 !important; }
.fc-button-primary {
  background: var(--gradient) !important;
  border-color: var(--primary) !important;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}
.empty-state i {
  font-size: 3rem;
  color: var(--border);
  display: block;
  margin-bottom: 12px;
}
.empty-state p {
  color: var(--text-muted);
  font-size: .85rem;
}

/* ── Utility Classes ───────────────────────────────────────── */
.text-primary-custom { color: var(--primary) !important; }
.bg-primary-custom   { background: var(--primary) !important; }
.bg-gradient-custom  { background: var(--gradient) !important; }

.rounded-custom      { border-radius: var(--radius) !important; }
.shadow-custom       { box-shadow: var(--shadow) !important; }

.bg-purple-light  { background: var(--primary-light); }
.bg-blue-light    { background: var(--secondary-light); }
.bg-green-light   { background: var(--success-light); }
.bg-red-light     { background: var(--danger-light); }
.bg-yellow-light  { background: var(--warning-light); }
.bg-cyan-light    { background: var(--info-light); }

.text-purple { color: var(--primary); }
.text-blue   { color: var(--secondary); }

/* ── Scroll area ───────────────────────────────────────────── */
.page-scroll { overflow-y: auto; }

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .35s ease both; }

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}
.pulse { animation: pulse-dot 1.5s infinite; }

/* ── Toast ─────────────────────────────────────────────────── */
.toast-container { z-index: 9999 !important; }

/* ── Search Bar ────────────────────────────────────────────── */
.search-wrap {
  padding: 10px 16px;
  background: transparent;
}
.search-input {
  border-radius: 14px !important;
  background: #fff !important;
  border: 1.5px solid var(--border) !important;
  padding-left: 40px !important;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ── Divider ───────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 0 16px;
}

/* ── Desktop centering shadow ──────────────────────────────── */
@media (min-width: 481px) {
  .app-wrapper {
    box-shadow: 0 0 60px rgba(0,0,0,.12);
    min-height: 100vh;
  }
  .bottom-nav { border-radius: 0; }
}
