/* ==========================================================================
   EduPulse Mobile - Teacher & Parent Portal Theme CSS
   Design: Modern Mobile First with Glassmorphism Bottom Tab Bar
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eeefff;
  --primary-glow: rgba(79, 70, 229, 0.25);
  
  --secondary: #06b6d4;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;

  --bg-page: #f1f5f9;
  --bg-app: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
  --border-radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.12);
  --shadow-tab: 0 -4px 20px rgba(0, 0, 0, 0.06);

  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --app-max-width: 480px;
  --bottom-bar-height: 68px;
}

/* Dark Mode Overrides */
body.dark-mode {
  --bg-page: #0b0f19;
  --bg-app: #111827;
  --bg-card: #1f2937;
  --bg-subtle: #182232;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --primary-light: rgba(79, 70, 229, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-tab: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 0;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Outer Desktop Frame Container */
.desktop-wrapper {
  width: 100%;
  max-width: var(--app-max-width);
  min-height: 100vh;
  background-color: var(--bg-app);
  box-shadow: var(--shadow-lg);
  position: relative;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease;
}

@media (min-width: 600px) {
  body {
    padding: 20px 0;
  }
  .desktop-wrapper {
    min-height: 840px;
    height: 840px;
    border-radius: 36px;
    border: 8px solid #1e293b;
    overflow: hidden;
  }
}

/* Top App Bar */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-app);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.3s ease;
}

.header-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-container {
  position: relative;
  width: 44px;
  height: 44px;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-full);
  object-fit: cover;
  border: 2px solid var(--primary);
}

.status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background-color: var(--success);
  border: 2px solid var(--bg-app);
  border-radius: 50%;
}

.user-text-greeting {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.user-text-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

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

/* Role Toggle Pill */
.role-toggle-pill {
  display: flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-full);
  padding: 3px;
  gap: 2px;
}

.role-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--border-radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.role-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 9px;
  height: 9px;
  background-color: var(--danger);
  border-radius: 50%;
}

/* Main Content Area */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px calc(var(--bottom-bar-height) + 24px) 16px;
  scroll-behavior: smooth;
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-panel.active {
  display: block;
}

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

/* Card Styling */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;

  color: var(--text-main);
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Quick Banner Card */
.banner-card {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  border: none;
  position: relative;
  overflow: hidden;
}

.banner-card::after {
  content: '';
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  pointer-events: none;
}

.banner-tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 3px 10px;
  border-radius: var(--border-radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.banner-heading {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.banner-desc {
  font-size: 0.8rem;
  opacity: 0.9;
  margin-bottom: 12px;
}

.banner-btn {
  background: #ffffff;
  color: var(--primary);
  border: none;
  padding: 8px 16px;
  border-radius: var(--border-radius-full);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.banner-btn:active {
  transform: scale(0.95);
}

/* Grid Action Buttons */
.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 12px 6px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-tile:hover, .action-tile:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.action-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.bg-purple { background: #e0e7ff; color: #4338ca; }
.bg-emerald { background: #d1fae5; color: #047857; }
.bg-amber { background: #fef3c7; color: #b45309; }
.bg-rose { background: #ffe4e6; color: #be123c; }

body.dark-mode .bg-purple { background: rgba(79, 70, 229, 0.25); color: #818cf8; }
body.dark-mode .bg-emerald { background: rgba(16, 185, 129, 0.25); color: #34d399; }
body.dark-mode .bg-amber { background: rgba(245, 158, 11, 0.25); color: #fbbf24; }
body.dark-mode .bg-rose { background: rgba(244, 63, 94, 0.25); color: #f87171; }

.action-label {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
}

/* Schedule & Attendance Widgets */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-radius: var(--border-radius-sm);
  border-left: 4px solid var(--primary);
  gap: 12px;
}

.timeline-item.done {
  border-left-color: var(--success);
}

.timeline-time {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 55px;
}

.timeline-info h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.timeline-info p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Stat Gauge Ring */
.stat-ring-container {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 0;
}

.ring-stat {
  text-align: center;
}

.ring-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.ring-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Student Switcher Bar (For Parents) */
.student-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary-light);
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  margin-bottom: 16px;
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.student-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.student-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.student-class {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.switch-btn-sm {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--border-radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

/* Chat & Messages */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.chat-item:hover {
  background: var(--bg-subtle);
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-content {
  flex: 1;
}

.chat-name {
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}

.chat-time {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
}

.chat-msg {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Digital Rapor / Grade Cards */
.grade-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border-radius: var(--border-radius-sm);
  margin-bottom: 8px;
}

.grade-subject {
  font-size: 0.88rem;
  font-weight: 600;
}

.grade-score {
  font-size: 1rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--border-radius-sm);
}

.score-a { background: #d1fae5; color: #047857; }
.score-b { background: #e0e7ff; color: #4338ca; }
.score-c { background: #fef3c7; color: #b45309; }

/* ==========================================================================
   FIXED BOTTOM TAB BAR (Core Feature)
   ========================================================================== */
.bottom-tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  height: var(--bottom-bar-height);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 1000;
  padding: 0 6px;
  box-shadow: var(--shadow-tab);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .bottom-tab-bar {
  background: rgba(17, 24, 39, 0.9);
  border-top-color: #374151;
}

@media (min-width: 600px) {
  .bottom-tab-bar {
    border-bottom-left-radius: 28px;
    border-bottom-right-radius: 28px;
  }
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.tab-icon {
  font-size: 1.35rem;
  margin-bottom: 2px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  transition: color 0.25s ease;
}

/* Active Tab Highlight */
.tab-item.active {
  color: var(--primary);
}

.tab-item.active .tab-icon {
  transform: translateY(-2px) scale(1.15);
}

.tab-item.active::after {
  content: '';
  position: absolute;
  top: 4px;
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
  animation: tabPillIn 0.25s ease forwards;
}

@keyframes tabPillIn {
  from { width: 0; opacity: 0; }
  to { width: 24px; opacity: 1; }
}

/* Floating Center Action Button (QR Presensi) */
.tab-item-center {
  top: -14px;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  border-radius: 50%;
  color: #ffffff !important;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
  border: 4px solid var(--bg-app);
}

.tab-item-center .tab-icon {
  font-size: 1.5rem;
  margin-bottom: 0;
  color: #ffffff;
}

.tab-item-center:active {
  transform: scale(0.92);
}

/* Modal Bottom Sheets */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  width: 100%;
  max-width: var(--app-max-width);
  background: var(--bg-card);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 24px 20px 36px 20px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  margin: 0 auto 16px auto;
}

.sheet-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

/* Scanner Simulation */
.qr-scanner-box {
  width: 200px;
  height: 200px;
  border: 3px dashed var(--primary);
  border-radius: var(--border-radius-md);
  margin: 16px auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  overflow: hidden;
}

.scan-beam {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  box-shadow: 0 0 12px var(--primary);
  animation: scanAnim 2s infinite linear;
}

@keyframes scanAnim {
  0% { top: 0; }
  50% { top: 195px; }
  100% { top: 0; }
}

.btn-primary-block {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--border-radius-full);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

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