/* ==========================================================
   MASEER SaaS - Professional Stylesheet (style.css)
   نظام مسير لإدارة المؤسسات التعليمية (Responsive & Accessible)
   ========================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg-body: #f8fafc;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text: #94a3b8;
  --card-bg: #ffffff;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  
  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-body);
  color: var(--text-dark);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ================= Sidebar Layout ================= */
.sidebar {
  width: 270px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1100;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

html[dir="ltr"] .sidebar {
  border-left: none;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
  padding: 24px 20px;
  text-align: center;
  border-bottom: 1px solid #1e293b;
  color: #fff;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.sidebar-header h2 {
  font-size: 16.5px;
  font-weight: 800;
  color: #ffffff;
  word-break: break-word;
  line-height: 1.4;
}

.sidebar-header p {
  font-size: 11.5px;
  color: var(--sidebar-text);
  margin-top: 4px;
}

.sidebar-menu {
  list-style: none;
  padding: 16px 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.sidebar-menu a:hover {
  background: var(--sidebar-hover);
  color: #f8fafc;
}

.sidebar-menu a.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.sidebar-menu i {
  width: 20px;
  text-align: center;
  font-size: 15px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-sidebar-logout {
  width: 100%;
  padding: 9px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #f87171;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: 0.2s;
}

.btn-sidebar-logout:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

/* ================= Main Content Layout ================= */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

header {
  background: var(--card-bg);
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 1000;
}

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

.header-title h1 {
  font-size: 18.5px;
  font-weight: 800;
  color: var(--text-dark);
}

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

.mobile-toggle {
  display: none;
  background: var(--primary);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.auto-save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--border-light);
  color: var(--text-muted);
  transition: 0.3s;
}
.auto-save-indicator.saving {
  background: var(--warning-bg);
  color: var(--warning);
}
.auto-save-indicator.saved {
  background: var(--success-bg);
  color: var(--success);
}

/* Custom Language Dropdown (No Select) */
.custom-dropdown-wrap {
  position: relative;
}
.lang-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
  cursor: pointer;
  transition: 0.2s;
}
.lang-dropdown-btn:hover {
  border-color: var(--primary);
}
.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  list-style: none;
  display: none;
  z-index: 1050;
  overflow: hidden;
}
html[dir="rtl"] .lang-dropdown-menu {
  left: 0;
  right: auto;
}
.lang-dropdown-menu.show {
  display: block;
}
.lang-dropdown-menu li {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: 0.15s;
}
.lang-dropdown-menu li:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ================= Content Area & Sections ================= */
.content-area {
  flex: 1;
  padding: 24px;
}

.page-section {
  display: none;
}
.page-section.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.stat-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  flex-shrink: 0;
}

.stat-details h3 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-dark);
  line-height: 1.2;
}
.stat-details p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header h3 {
  font-size: 16.5px;
  font-weight: 800;
  color: var(--text-dark);
}

/* Buttons */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #059669;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
}
.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-warning:hover {
  background: #d97706;
}
.btn-purple {
  background: var(--purple);
  color: #fff;
}
.btn-purple:hover {
  background: #7c3aed;
}
.btn-secondary {
  background: #f1f5f9;
  color: var(--text-dark);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: #e2e8f0;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Forms & Inputs */
.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 13.5px;
  margin-top: 6px;
  background: #ffffff;
  color: var(--text-dark);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.checkbox-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.checkbox-group input[type="checkbox"] {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  min-width: 680px;
}
html[dir="ltr"] table {
  text-align: left;
}
th, td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13.5px;
  white-space: nowrap;
}
th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 800;
  font-size: 12.5px;
}
tr:hover {
  background: #f8fafc;
}
tr.debt-warning {
  background: #fffbeb;
}
tr.debt-danger {
  background: #fef2f2;
}

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-purple { background: var(--purple-bg); color: #5b21b6; }

.consecutive-absence-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fee2e2;
  color: #991b1b;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  margin-right: 6px;
}

.class-checkbox-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: #f8fafc;
}
.class-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--border-color);
  font-size: 13px;
  cursor: pointer;
}
.class-checkbox-item:last-child {
  border-bottom: none;
}
.class-checkbox-item input {
  width: 16px;
  height: 16px;
}
.class-checkbox-item .cname {
  flex: 1;
  font-weight: 600;
}
.class-checkbox-item .cprice {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 35px 20px;
  font-weight: 600;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 16px;
}
.modal.active {
  display: flex;
  animation: modalFade 0.2s ease-out;
}
@keyframes modalFade {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content {
  background: var(--card-bg);
  padding: 26px;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
  font-size: 17px;
  font-weight: 800;
}
.modal-header button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}

.attendance-radio-group label {
  margin-left: 12px;
  margin-right: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.attendance-radio-group input {
  margin-left: 4px;
  margin-right: 4px;
}

/* Progress bar for attendance */
.progress-wrap {
  width: 80px;
  height: 8px;
  background: #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
}
.progress-bar {
  height: 100%;
  background: var(--success);
}

/* Student ID Card / QR Card View */
.student-qr-card {
  border: 2px dashed #93c5fd;
  border-radius: var(--radius-md);
  padding: 20px;
  background: #f0fdf4;
  text-align: center;
  margin: 15px 0;
}
.student-qr-card .qr-container {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

/* Feature Locked Banner / Overlay */
.feature-locked-box {
  background: #fdf4ff;
  border: 1px solid #e879f9;
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  margin: 15px 0;
}
.feature-locked-box i {
  font-size: 36px;
  color: #a855f7;
  margin-bottom: 12px;
}

/* ================= Print Layout (Fixed Receipt Printing) ================= */
#print-receipt-area {
  display: none;
}

@media print {
  .no-print {
    display: none !important;
  }
  html, body {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .sidebar, .main-wrapper > header, .content-area > section, .mobile-toggle, .modal {
    display: none !important;
  }
  body.printing-receipt * {
    visibility: hidden !important;
  }
  body.printing-receipt #print-receipt-area,
  body.printing-receipt #print-receipt-area * {
    visibility: visible !important;
  }
  body.printing-receipt #print-receipt-area {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    padding: 20px !important;
    margin: 0 !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
  }
  #print-receipt-area > div {
    border: 2px solid #0f172a !important;
    box-shadow: none !important;
    margin: 0 auto !important;
    page-break-inside: avoid !important;
    background: #fff !important;
  }
}

/* ================= Mobile & Tablet Responsive ================= */
@media (max-width: 900px) {
  .mobile-toggle {
    display: flex;
  }
  .sidebar {
    position: fixed;
    right: -280px;
    top: 0;
    height: 100vh;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
  }
  html[dir="ltr"] .sidebar {
    right: auto;
    left: -280px;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.open {
    right: 0;
  }
  html[dir="ltr"] .sidebar.open {
    left: 0;
  }
  .content-area {
    padding: 16px 14px 80px;
  }
  header {
    padding: 14px 16px;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
}
