/* ===================================================================
   RUMAH TAHFIZ MANAGEMENT SYSTEM - STYLESHEET
   Design System: Quartz — Modern Minimalist Islamic Edition
   Palette: #F1F2FA (bg) · #4C7AF1 (blue/primary) · #42CDAD (teal) · #F6BC41 (amber)
   =================================================================== */

:root {
  --primary: #4C7AF1;         /* Quartz blue — primary actions, active states */
  --primary-dark: #3a68d8;    /* Darker blue for hover */
  --primary-darker: #2a4fa0;  /* Deep blue for headings, strong emphasis */
  --primary-light: #7097f5;   /* Light blue for subtle highlights */
  --primary-surface: #eef2fe; /* Very light blue tint for surface backgrounds */
  --primary-border: #c3d2fc;  /* Light blue border */

  --accent-teal: #42CDAD;     /* Quartz teal — secondary accent, success states */
  --accent-teal-bg: #e8faf6;  /* Teal surface tint */
  --accent-teal-border: #9fe8d9; /* Teal border */

  --accent-gold: #F6BC41;     /* Quartz amber — highlights, gold badges */
  --accent-gold-light: #fef7e0; /* Amber surface tint */

  --bg-main: #F1F2FA;         /* Quartz off-white — page background */
  --bg-card: #ffffff;
  --bg-subtle: #e8eaf5;       /* Slightly tinted surface for nested sections */

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --border-color: #e2e8f0;

  --status-present: #42CDAD;    /* Quartz teal — attendance present */
  --status-present-bg: #e8faf6;
  --status-permit: #d97706;
  --status-permit-bg: #fffbeb;
  --status-sick: #2563eb;
  --status-sick-bg: #eff6ff;
  --status-absent: #dc2626;
  --status-absent-bg: #fef2f2;
  --status-late: #7c3aed;
  --status-late-bg: #f5f3ff;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --sidebar-width: 260px;
  --header-height: 64px;
  --bottom-nav-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.arabic-text {
  font-family: "Amiri", "Traditional Arabic", "Scheherazade New", Tahoma, serif;
  direction: rtl;
  font-size: 1.25em;
  line-height: 1.6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Base Layout */
#app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar (Desktop) */
#sidebar {
  width: var(--sidebar-width);
  background-color: #1e3a6e;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #4C7AF1, #42CDAD);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-title-box h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-title-box p {
  font-size: 11px;
  color: #93b4f8;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #7097f5;
  letter-spacing: 1px;
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #c8d8fc;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  margin-bottom: 3px;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-item.active {
  background-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

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

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background-color: rgba(0, 0, 0, 0.15);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: #4C7AF1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 14px;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-tag {
  font-size: 10px;
  color: #93b4f8;
  text-transform: capitalize;
}

.btn-logout-mini {
  background: transparent;
  border: none;
  color: #fca5a5;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 16px;
}

.btn-logout-mini:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Main Content Area */
#main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
#top-header {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-main);
}

.page-title-box h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.page-title-box p {
  font-size: 12px;
  color: var(--text-muted);
}

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

/* Page Content Viewport */
#content-viewport {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Bottom Mobile Navigation */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.bottom-nav-item.active {
  color: var(--primary);
  font-weight: 700;
}

.bottom-nav-item .icon {
  font-size: 20px;
  margin-bottom: 2px;
}

/* Reusable Components */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

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

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

.btn-secondary:hover {
  background-color: var(--bg-subtle);
}

.btn-outline-primary {
  background-color: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

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

.btn-danger {
  background-color: #ef4444;
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background-color: var(--primary-surface);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-icon.gold { background-color: #fef3c7; color: #d97706; }
.stat-icon.blue { background-color: #eff6ff; color: #2563eb; }
.stat-icon.purple { background-color: #f5f3ff; color: #7c3aed; }
.stat-icon.red { background-color: #fef2f2; color: #dc2626; }

.stat-details {
  flex: 1;
}

.stat-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
}

.stat-subtext {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* Forms & Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  background-color: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.form-control {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

select.form-control {
  cursor: pointer;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

table.data-table th {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tr:hover {
  background-color: #fafbfc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.badge-present { background-color: var(--status-present-bg); color: var(--status-present); border: 1px solid var(--accent-teal-border); }
.badge-permit  { background-color: var(--status-permit-bg);  color: var(--status-permit);  border: 1px solid #fde68a; }
.badge-sick    { background-color: var(--status-sick-bg);    color: var(--status-sick);    border: 1px solid #bfdbfe; }
.badge-absent  { background-color: var(--status-absent-bg);  color: var(--status-absent);  border: 1px solid #fecaca; }
.badge-late    { background-color: var(--status-late-bg);    color: var(--status-late);    border: 1px solid #ddd6fe; }
.badge-active  { background-color: var(--accent-teal-bg); color: #1a7a63; }
.badge-inactive { background-color: #f1f5f9; color: #64748b; }

/* Progress Bar */
.progress-container {
  width: 100%;
  background-color: #e2e8f0;
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
  margin: 6px 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #42CDAD, #4C7AF1);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-dialog {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalEnter 0.2s ease-out;
}

.modal-dialog.modal-lg {
  max-width: 900px;
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 280px;
  max-width: 400px;
  background-color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 4px solid var(--primary);
  font-size: 13px;
  animation: toastIn 0.3s ease;
}

.toast.toast-error { border-left-color: #ef4444; }
.toast.toast-warning { border-left-color: #d97706; }
.toast.toast-info { border-left-color: #2563eb; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Attendance Mass Input Grid */
.attendance-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.attendance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  gap: 12px;
  flex-wrap: wrap;
}

.att-student-info {
  flex: 1;
  min-width: 180px;
}

.att-student-name {
  font-weight: 600;
  font-size: 13px;
}

.att-student-nis {
  font-size: 11px;
  color: var(--text-muted);
}

.att-status-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.status-choice-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.status-choice-btn:hover {
  background-color: var(--bg-subtle);
}

.status-choice-btn.selected-present {
  background-color: var(--status-present);
  color: #fff;
  border-color: var(--status-present);
}

.status-choice-btn.selected-permit {
  background-color: var(--status-permit);
  color: #fff;
  border-color: var(--status-permit);
}

.status-choice-btn.selected-sick {
  background-color: var(--status-sick);
  color: #fff;
  border-color: var(--status-sick);
}

.status-choice-btn.selected-absent {
  background-color: var(--status-absent);
  color: #fff;
  border-color: var(--status-absent);
}

.status-choice-btn.selected-late {
  background-color: var(--status-late);
  color: #fff;
  border-color: var(--status-late);
}

/* Print Layout for Rapor Santri */
@media print {
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
  }

  #sidebar, #top-header, #bottom-nav, .no-print, .btn, .filter-bar {
    display: none !important;
  }

  #main-wrapper {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  #content-viewport {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .print-card-rapor {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }

  .rapor-kop {
    text-align: center;
    border-bottom: 3px double #000;
    padding-bottom: 12px;
    margin-bottom: 16px;
  }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #main-wrapper {
    margin-left: 0;
    padding-bottom: var(--bottom-nav-height);
  }

  .menu-toggle-btn {
    display: block;
  }

  #bottom-nav {
    display: flex;
  }

  #top-header {
    padding: 0 16px;
  }

  #content-viewport {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

  .header-actions .btn-text-hide {
    display: none;
  }

  .attendance-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
