/* ========================================
   Global Styles - School Control System
   ======================================== */

@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap");

:root {
  /* Brand Colors */
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #818cf8;
  --primary-50: #eef2ff;

  --accent: #06b6d4;
  --accent-dark: #0891b2;

  --success: #10b981;
  --success-dark: #059669;
  --warning: #f59e0b;
  --warning-dark: #d97706;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --info: #3b82f6;

  /* Neutrals */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #111827;
  --text-soft: #4b5563;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  /* Sidebar */
  --sidebar-bg: #1e293b;
  --sidebar-bg-2: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-text-active: #ffffff;
  --sidebar-active: #4f46e5;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --header-h: 64px;
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 72px;

  --transition: all 0.25s ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Cairo", "Tahoma", sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  color: var(--primary-dark);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 0.5em;
  font-weight: 700;
  color: var(--text);
}

img {
  max-width: 100%;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
  background: transparent;
  color: var(--text);
  line-height: 1;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
  background: var(--primary-dark);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: var(--success-dark);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-dark);
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}
.btn-warning:hover {
  background: var(--warning-dark);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-soft);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 26px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

/* ----- Forms ----- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}
.form-label .req {
  color: var(--danger);
  margin-inline-start: 4px;
}

.form-control,
.form-select {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  outline: none;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.form-control::placeholder {
  color: var(--text-faint);
}

.form-row {
  display: grid;
  gap: 16px;
}
.form-row.cols-2 {
  grid-template-columns: 1fr 1fr;
}
.form-row.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 768px) {
  .form-row.cols-2,
  .form-row.cols-3 {
    grid-template-columns: 1fr;
  }
}

.form-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ----- Cards ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.card-header h3 {
  margin: 0;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-header h3 i {
  color: var(--primary);
}

.card-body {
  padding: 22px;
}

/* ----- Tables ----- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
}

.data-table thead th {
  background: var(--surface-2);
  color: var(--text-soft);
  font-weight: 700;
  font-size: 13px;
  padding: 14px 16px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background 0.15s ease;
}
.data-table tbody tr:hover {
  background: var(--surface-2);
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.row-actions .btn-icon {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 56px;
  color: var(--text-faint);
  margin-bottom: 16px;
  display: block;
}
.empty-state h4 {
  color: var(--text-soft);
  margin: 0 0 6px;
}

/* ----- Badges ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.badge-primary {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  border-color: rgba(79, 70, 229, 0.2);
}
.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-dark);
  border-color: rgba(16, 185, 129, 0.25);
}
.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning-dark);
  border-color: rgba(245, 158, 11, 0.25);
}
.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-dark);
  border-color: rgba(239, 68, 68, 0.25);
}
.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
  border-color: rgba(59, 130, 246, 0.25);
}

/* ----- Modal ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 20px;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.96);
  transition: transform 0.25s ease;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
}

.modal-lg {
  max-width: 800px;
}
.modal-xl {
  max-width: 1100px;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.modal-header h3 {
  margin: 0;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-header h3 i {
  color: var(--primary);
}
.modal-close {
  background: transparent;
  border: 0;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.modal-close:hover {
  background: var(--surface-2);
  color: var(--danger);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ----- Toast ----- */
.toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.app-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  transform: translateX(-120%);
  opacity: 0;
  transition: all 0.3s ease;
}
.app-toast.show {
  transform: translateX(0);
  opacity: 1;
}
.app-toast i {
  font-size: 18px;
}

/* ----- Confirm Dialog ----- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1500;
  opacity: 0;
  transition: opacity 0.25s ease;
  padding: 20px;
}
.confirm-overlay.show {
  opacity: 1;
}

.confirm-box {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: scale(0.92);
  transition: transform 0.25s ease;
}
.confirm-overlay.show .confirm-box {
  transform: scale(1);
}
.confirm-icon {
  width: 64px;
  height: 64px;
  background: rgba(245, 158, 11, 0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.confirm-icon i {
  font-size: 28px;
  color: var(--warning);
}
.confirm-box h3 {
  margin: 0 0 8px;
}
.confirm-box p {
  color: var(--text-muted);
  margin: 0 0 24px;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ----- Utility ----- */
.text-center {
  text-align: center;
}
.text-muted {
  color: var(--text-muted);
}
.text-soft {
  color: var(--text-soft);
}
.text-success {
  color: var(--success);
}
.text-danger {
  color: var(--danger);
}
.text-warning {
  color: var(--warning);
}
.text-primary {
  color: var(--primary);
}

.flex {
  display: flex;
}
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.gap-sm {
  gap: 6px;
}
.gap {
  gap: 12px;
}
.gap-lg {
  gap: 20px;
}

.mt-2 {
  margin-top: 8px;
}
.mt-3 {
  margin-top: 16px;
}
.mt-4 {
  margin-top: 24px;
}

.hidden {
  display: none !important;
}

/* ----- Loader ----- */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(79, 70, 229, 0.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.spinner-lg {
  width: 38px;
  height: 38px;
  border-width: 4px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  border-radius: inherit;
}

/* ----- Page Loader ----- */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  z-index: 9999;
  transition: opacity 0.4s ease;
}
.page-loader.hide {
  opacity: 0;
  pointer-events: none;
}

/* ----- Connection Indicator ----- */
.conn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-dark);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-weight: 600;
}
.conn-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  animation: pulse 1.6s infinite;
}
.conn-indicator.offline {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-dark);
  border-color: rgba(239, 68, 68, 0.25);
}
.conn-indicator.offline .dot {
  background: var(--danger);
  animation: none;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* ----- Search Box ----- */
.search-box {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-box input {
  padding-inline-start: 38px;
}
.search-box i {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}
