/* ==========================================================================
   EDUPULSE TUITION ECOSYSTEM - SAAS WHITE-LABEL DESIGN SYSTEM
   ========================================================================== */

:root {
  /* Dynamic White-Label Brand Theme Overrides */
  --brand-primary: #6366f1;
  --brand-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

  /* Color Palette */
  --primary: var(--brand-primary);
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.12);
  
  --secondary: #0ea5e9;
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.12);

  /* Role Badges Accents */
  --role-admin: #8b5cf6;
  --role-teacher: #10b981;
  --role-student: #0ea5e9;
  --role-parent: #f59e0b;

  /* Surface & Background (Light Mode) */
  --bg-app: #f8fafc;
  --bg-header: rgba(255, 255, 255, 0.88);
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-color: #e2e8f0;
  
  /* Text Colors */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Shadows & Glassmorphism */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --glass-backdrop: blur(12px);

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
}

/* Dark Mode Variables */
body.dark-theme {
  --bg-app: #090d16;
  --bg-header: rgba(15, 23, 42, 0.88);
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border-color: #334155;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
}

/* Reset & Base Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header & Top Nav */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-header);
  backdrop-filter: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-backdrop);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  overflow: hidden;
}

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-icon svg {
  width: 24px;
  height: 24px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Role Switcher Bar */
.role-switcher-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  padding: 0.35rem 0.5rem;
  border-radius: 30px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.switcher-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-left: 0.5rem;
}

.switcher-label svg {
  width: 14px;
  height: 14px;
  color: var(--primary);
}

.role-buttons {
  display: flex;
  gap: 0.3rem;
}

.role-btn {
  border: none;
  background: transparent;
  padding: 0.45rem 0.85rem;
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.role-btn svg {
  width: 15px;
  height: 15px;
}

.role-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.role-btn.active[data-role="admin"] {
  background: var(--role-admin);
  color: white;
  box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.role-btn.active[data-role="teacher"] {
  background: var(--role-teacher);
  color: white;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.role-btn.active[data-role="student"] {
  background: var(--role-student);
  color: white;
  box-shadow: 0 4px 10px rgba(14, 165, 233, 0.3);
}

.role-btn.active[data-role="parent"] {
  background: var(--role-parent);
  color: white;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

/* User Badge & Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  padding: 0.35rem 0.75rem 0.35rem 0.4rem;
  border-radius: 30px;
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.1;
}

.user-role-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Mobile Role Picker */
.mobile-role-picker {
  display: none;
  background: var(--bg-card);
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.mobile-role-picker select {
  width: 100%;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  color: var(--text-main);
  font-weight: 600;
}

/* Main Viewport & Layout */
.main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Portal Banner & Section Header */
.portal-banner {
  background: var(--brand-gradient);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.portal-banner::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 300px;
  height: 300px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  pointer-events: none;
}

.portal-title-group h1 {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.portal-title-group p {
  font-size: 0.9rem;
  opacity: 0.9;
}

.portal-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-warning {
  background: var(--warning);
  color: white;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-light {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  backdrop-filter: blur(8px);
}

.btn-light:hover {
  background: rgba(255, 255, 255, 0.3);
}

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

.btn-outline:hover {
  background: var(--bg-card-hover);
}

/* Form Elements & Inputs */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.88rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

/* Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric-info .metric-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.metric-info .metric-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
}

.metric-info .metric-subtext {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 0.4rem;
}

.metric-subtext.positive { color: var(--success); }
.metric-subtext.warning { color: var(--warning); }
.metric-subtext.danger { color: var(--danger); }

.metric-icon-wrapper {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.metric-icon-wrapper.purple { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.metric-icon-wrapper.blue { background: rgba(14, 165, 233, 0.12); color: #0ea5e9; }
.metric-icon-wrapper.green { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.metric-icon-wrapper.amber { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }

/* Portal Grid Layout */
.portal-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .portal-grid {
    grid-template-columns: 1fr;
  }
}

/* Glassmorphism Section Card */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.card-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title svg {
  color: var(--primary);
  width: 20px;
  height: 20px;
}

/* Graph Canvas Container */
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 320px;
  margin-top: 0.5rem;
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.custom-table th {
  background: var(--bg-card-hover);
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.custom-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.custom-table tbody tr:hover {
  background-color: var(--bg-card-hover);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-present, .badge-paid {
  background: var(--success-light);
  color: var(--success);
}

.badge-absent, .badge-unpaid {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-late, .badge-pending {
  background: var(--warning-light);
  color: var(--warning);
}

/* Attendance Marker Card */
.attendance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.student-att-card {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.att-actions {
  display: flex;
  gap: 0.35rem;
}

.att-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.att-btn.active-p { background: var(--success); color: white; border-color: var(--success); }
.att-btn.active-a { background: var(--danger); color: white; border-color: var(--danger); }
.att-btn.active-l { background: var(--warning); color: white; border-color: var(--warning); }

/* Announcements Feed */
.announcement-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.announcement-item {
  background: var(--bg-app);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1rem;
}

.announcement-item.urgent {
  border-left-color: var(--danger);
  background: rgba(239, 68, 68, 0.04);
}

.announcement-item.exam {
  border-left-color: var(--secondary);
}

.announcement-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.ann-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.ann-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.ann-content {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  animation: modalPop 0.25s ease-out;
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

/* Printable Report Card Styles */
.report-card-sheet {
  background: white;
  color: #0f172a;
  padding: 2rem;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
}

.report-header {
  text-align: center;
  border-bottom: 3px double #0f172a;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.report-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #4f46e5;
  margin-bottom: 0.2rem;
}

.report-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background: #f8fafc;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.report-table th, .report-table td {
  border: 1px solid #cbd5e1;
  padding: 0.65rem;
  text-align: left;
}

.report-table th {
  background: #e2e8f0;
  font-weight: 700;
}

.report-signature-row {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px dashed #cbd5e1;
  font-weight: 600;
  font-size: 0.85rem;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 0.88rem;
  animation: slideUp 0.3s ease-out;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.info { border-left: 4px solid var(--primary); }

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

/* Responsive Media Queries */
@media (max-width: 860px) {
  .role-switcher-container {
    display: none;
  }
  .mobile-role-picker {
    display: block;
  }
  .portal-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 540px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .main-content {
    padding: 1rem;
  }
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Printable Media CSS */
@media print {
  body * {
    visibility: hidden;
  }
  .printable-area, .printable-area * {
    visibility: visible;
  }
  .printable-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
}
