/* ----------------------------------------------------
   MOBILE-FIRST BASE STYLES (Default for Mobile Screens)
   ---------------------------------------------------- */

/* Reset & Root Variables (Official SD Negeri Bobong Design Tokens & Apple HIG Standard) */
:root {
  /* 1. Warna Utama (Primary) - Biru Toska Logo */
  --primary: #12A5B8;
  --primary-light: #48C4D3;
  --primary-dark: #0A7E8D;
  --primary-hover: #0A7E8D;

  /* 2. Warna Sekunder (Secondary) - Kuning Emas Logo */
  --secondary: #E5A900;
  --secondary-light: #FFC83B;
  --secondary-dark: #B28300;

  /* 3. Warna Aksen (Accent) - Hijau Daun */
  --accent: #2A9D5C;
  --accent-bg: #EBF7F0;

  /* 4. Warna Latar Belakang (Background) */
  --bg-main: #F5F5F7;
  --bg-card: #FFFFFF;
  --card-bg: #FFFFFF;
  --bg-footer: #122438;
  --bg-footer-deep: #0A1624;

  /* 5. Warna Teks (Typography) */
  --text-main: #1D1D1F;
  --text-muted: #515154;
  --text-light: #86868B;

  /* Layout & Utility Tokens */
  --sidebar-bg: rgba(255, 255, 255, 0.95);
  --sidebar-active: #E6F7F9;
  --sidebar-text: #515154;
  --sidebar-active-text: #0A7E8D;
  --border-color: rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(18, 165, 184, 0.12);
  --shadow-lg: 0 12px 32px rgba(10, 126, 141, 0.18);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-full: 9999px;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Plus Jakarta Sans", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Sidebar Drawer - Mobile First (Hidden Off-Canvas by Default) */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 82vw;
  max-width: 290px;
  height: 100vh;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 16px;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
}

.sidebar.active {
  transform: translateX(0);
}

/* Backdrop for Mobile Sidebar */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(3px);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 14px;
}

.logo-badge {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #216c7e, #164d57);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.school-info h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.school-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px; /* Touch friendly */
  transition: all 0.2s ease;
}

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

.nav-item.active {
  background-color: var(--sidebar-active);
  color: var(--sidebar-active-text);
}

.nav-item i {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

/* Teacher Profile Card at Bottom */
.teacher-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 12px;
}

.teacher-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
}

.teacher-details h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.teacher-details p {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Main Content Wrapper - Mobile First */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  overflow-y: auto;
}

/* Top Bar Mobile */
.top-bar {
  background: white;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-title h2 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
}

.top-title p {
  font-size: 11.5px;
  color: var(--text-muted);
  display: none; /* Hide subtitle on mobile screen for cleanliness */
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-main);
}

/* Content Area - Mobile Padding */
.content-area {
  padding: 16px;
  flex: 1;
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Banner Hero Mobile */
.hero-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: var(--radius-md);
  padding: 20px 18px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(18, 165, 184, 0.22);
}

.hero-text h1 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
}

.hero-text p {
  font-size: 13px;
  opacity: 0.95;
  line-height: 1.4;
}

.hero-badge {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 8px;
}

/* Stats Grid Mobile (Single/Two Column) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-icon.teal { background: #eef6f8; color: #216c7e; }
.stat-icon.emerald { background: #d1fae5; color: #047857; }
.stat-icon.amber { background: #fef3c7; color: #b45309; }
.stat-icon.rose { background: #ffe4e6; color: #be123c; }

.stat-info h4 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.stat-info p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Buttons Mobile */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  min-height: 40px; /* Touch friendly */
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

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

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

/* Cards & Responsive Tables (Apple HIG Standard) */
.card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 20px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 2px solid var(--border-color);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.badge {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  display: inline-block;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }

/* Modul Ajar Mobile Cards */
.module-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  background: white;
}

.module-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.module-header h3 {
  font-size: 15px;
  color: var(--primary-dark);
}

/* Flashcard Grid Mobile */
.flashcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.flashcard {
  perspective: 1000px;
  height: 190px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: white;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.flashcard-emoji {
  font-size: 40px;
  margin-bottom: 6px;
}

.flashcard-word {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.audio-btn {
  background: var(--primary);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-top: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modal Overlay Mobile */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end; /* Sheet style on mobile */
  justify-content: center;
  z-index: 2000;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.close-modal {
  background: #f1f5f9;
  border: none;
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-main);
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

/* ----------------------------------------------------
   DESKTOP & TABLET MEDIA QUERIES (Min-Width 992px)
   ---------------------------------------------------- */
@media (min-width: 992px) {
  .sidebar {
    position: static;
    transform: none;
    width: 280px;
    box-shadow: none;
  }

  .sidebar-backdrop {
    display: none !important;
  }

  .menu-toggle {
    display: none;
  }

  .top-bar {
    padding: 16px 28px;
  }

  .top-title h2 {
    font-size: 20px;
  }

  .top-title p {
    display: block;
    font-size: 13px;
  }

  .content-area {
    padding: 28px;
  }

  .hero-banner {
    padding: 28px;
  }

  .hero-text h1 {
    font-size: 24px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
  }

  .flashcard-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
  }

  .module-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }

  .modal-overlay {
    align-items: center;
  }

  .modal-content {
    border-radius: var(--radius-lg);
    animation: fadeIn 0.2s ease;
  }
}


/* ----------------------------------------------------
   LOGIN SCREEN STYLES (Mobile First)
   ---------------------------------------------------- */
.login-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, var(--bg-footer-deep) 0%, var(--bg-footer) 50%, var(--primary-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
  overflow-y: auto;
}

.login-card {
  background: #ffffff;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.school-logo-container {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.sd-logo-svg {
  filter: drop-shadow(0 4px 12px rgba(2, 132, 199, 0.25));
  transition: transform 0.3s ease;
}

.sd-logo-svg:hover {
  transform: scale(1.04);
}

.login-header-text h2 {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 0.5px;
}

.login-header-text .sub-school {
  font-size: 13px;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 8px;
}

.btn-login {
  width: 100%;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
  color: #ffffff !important;
  border: none;
  box-shadow: 0 8px 20px rgba(18, 165, 184, 0.35) !important;
  transition: all 0.3s var(--ease-spring);
}

.btn-login:hover {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-dark) 100%) !important;
  box-shadow: 0 10px 24px rgba(18, 165, 184, 0.45) !important;
  transform: translateY(-2px);
}

/* Redesigned Premium Apple HIG Grade Table */
.grade-table-card {
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.grade-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  white-space: nowrap;
}

.grade-table th {
  background: #f8fafc;
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 2px solid #e2e8f0;
}

.grade-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text-main);
}

.grade-table tr:hover {
  background-color: rgba(18, 165, 184, 0.03);
}

.grade-counter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  padding: 3px 6px;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
}

.grade-btn-step {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.grade-btn-step:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: scale(1.05);
}

.grade-input-num {
  width: 36px;
  border: none;
  background: transparent;
  text-align: center;
  font-weight: 800;
  font-size: 13.5px;
  color: var(--primary-dark);
  outline: none;
}

.na-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(18, 165, 184, 0.12);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 14.5px;
}

.kktp-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.kktp-badge.badge-success {
  background: #EBF7F0;
  color: #2A9D5C;
  border: 1px solid rgba(42, 157, 92, 0.3);
}

.kktp-badge.badge-info {
  background: #eef6f8;
  color: #0A7E8D;
  border: 1px solid rgba(18, 165, 184, 0.3);
}

.kktp-badge.badge-warning {
  background: #fffbeb;
  color: #B28300;
  border: 1px solid rgba(229, 169, 0, 0.3);
}

.kktp-badge.badge-danger {
  background: #fff1f2;
  color: #e11d48;
  border: 1px solid rgba(225, 29, 72, 0.3);
}
