/* public/style.css — النمط العام للنظام */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
  --primary: #50808e;
  --primary-dark: #3d6570;
  --secondary: #69a297;
  --light-1: #84b59f;
  --light-2: #a3c9a8;
  --background: #ddd8c4;
  --bg-card: #ffffff;
  --bg-sidebar: #2c3e50;
  --warning: #b8960c;
  --danger: #7b241c;
  --success: #145a32;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a5a;
  --text-light: #7a7a8a;
  --border: #d4d0c0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--background);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.7;
}

/* ════════════════════════════════════════════════ */
/*  شاشة تسجيل الدخول                             */
/* ════════════════════════════════════════════════ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--light-1) 100%);
  padding: 1rem;
}

.login-card {
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 3rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-card .logo {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 20px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* ════════════════════════════════════════════════ */
/*  نظام التخطيط الرئيسي                          */
/* ════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: linear-gradient(180deg, #1a2332 0%, #2c3e50 100%);
  color: white;
  padding: 1.5rem 0;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: var(--transition);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}

.sidebar-header {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 1rem;
}

.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--light-2);
}

.sidebar-header small {
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
}

.nav-item {
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition);
  border-right: 3px solid transparent;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
}

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

.nav-item.active {
  background: rgba(80, 128, 142, 0.3);
  color: var(--light-2);
  border-right-color: var(--light-2);
  font-weight: 600;
}

.nav-item .icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0.75rem 1.5rem;
}

.main-content {
  flex: 1;
  margin-right: 280px;
  padding: 2rem;
  min-height: 100vh;
}

/* ════════════════════════════════════════════════ */
/*  الرأس                                         */
/* ════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.page-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ════════════════════════════════════════════════ */
/*  البطاقات الإحصائية                            */
/* ════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.colleges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

/* تنسيق مدمج لجداول الأقسام داخل بطاقات الكليات */
.colleges-grid table th,
.colleges-grid table td {
  padding: 0.6rem 0.5rem;
  font-size: 0.84rem;
}

.colleges-grid table th:last-child,
.colleges-grid table td:last-child {
  white-space: nowrap;
  text-align: center;
  min-width: 90px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.secondary::before { background: var(--secondary); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }

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

.stat-card .stat-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.stat-card .stat-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* ════════════════════════════════════════════════ */
/*  الجداول                                        */
/* ════════════════════════════════════════════════ */
.table-container {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  margin-bottom: 2rem;
}

.table-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}

.table-header h3 {
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 1.1rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--background);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  max-width: 300px;
  width: 100%;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  direction: rtl;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: linear-gradient(to left, #f0f0ec, #e8e5d8);
}

thead th {
  padding: 0.9rem 1rem;
  text-align: right;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid #f0ede3;
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(163, 201, 168, 0.1);
}

tbody tr.selected {
  background: rgba(132, 181, 159, 0.15);
}

/* ════════════════════════════════════════════════ */
/*  الشارات (Badges)                              */
/* ════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-primary { background: rgba(80,128,142,0.12); color: var(--primary); }
.badge-success { background: rgba(20,90,50,0.12); color: var(--success); }
.badge-warning { background: rgba(184,150,12,0.12); color: var(--warning); }
.badge-danger  { background: rgba(123,36,28,0.12); color: var(--danger); }
.badge-info    { background: rgba(105,162,151,0.12); color: var(--secondary); }
.badge-professional { background: rgba(163,201,168,0.2); color: #2d6a4f; border: 1px solid rgba(163,201,168,0.4); }

/* ════════════════════════════════════════════════ */
/*  الأزرار                                        */
/* ════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

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

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { opacity: 0.9; }

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(80,128,142,0.08); }

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
}

/* ════════════════════════════════════════════════ */
/*  النماذج                                        */
/* ════════════════════════════════════════════════ */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.form-control {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition);
  direction: rtl;
  background: white;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(80,128,142,0.15);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%234a4a5a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 2.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 0.5rem 0;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ════════════════════════════════════════════════ */
/*  المودال                                        */
/* ════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

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

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.modal-header h3 {
  font-weight: 700;
  color: var(--primary-dark);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--background);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: var(--danger); color: white; }

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
  gap: 0.75rem;
}

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

/* ════════════════════════════════════════════════ */
/*  كشف الراتب                                     */
/* ════════════════════════════════════════════════ */
.payslip {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.payslip-header {
  text-align: center;
  border-bottom: 3px double var(--primary);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.payslip-section {
  margin-bottom: 1.5rem;
}

.payslip-section h4 {
  color: var(--primary);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.payslip-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.9rem;
}

.payslip-row .label { color: var(--text-secondary); }
.payslip-row .value { font-weight: 600; }
.payslip-row .deduction { color: var(--danger); }
.payslip-row .positive { color: var(--success); }

.payslip-total {
  background: linear-gradient(to left, rgba(80,128,142,0.08), rgba(163,201,168,0.08));
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
}

.cap-warning {
  background: rgba(184,150,12,0.1);
  border: 1px solid rgba(184,150,12,0.3);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #856404;
}

/* ════════════════════════════════════════════════ */
/*  التحميل والرسائل                              */
/* ════════════════════════════════════════════════ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-secondary);
  gap: 10px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  color: white;
  font-weight: 600;
  z-index: 2000;
  animation: slideDown 0.3s ease;
  box-shadow: var(--shadow-lg);
  max-width: 90%;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

@keyframes slideDown { from { opacity: 0; transform: translate(-50%, -20px); } to { opacity: 1; transform: translate(-50%, 0); } }

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }

/* ════════════════════════════════════════════════ */
/*  قسم خاص بالفلاتر                               */
/* ════════════════════════════════════════════════ */
.filters-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  align-items: flex-end;
}

.filters-bar .form-group {
  margin-bottom: 0;
  min-width: 180px;
}

.filters-bar .form-group label {
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.filters-bar .form-control {
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
}

/* ════════════════════════════════════════════════ */
/*  Responsive                                     */
/* ════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: relative;
    right: auto;
  }
  .main-content {
    margin-right: 0;
    padding: 1rem;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* تنسيق الطباعة */
@media print {
  .sidebar, .page-header .btn, .table-header .btn, .modal-overlay, .toast, .app-footer { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .stat-card { break-inside: avoid; }
  body { background: white; }
}

/* ════════════════════════════════════════════════ */
/*  الفوتر                                         */
/* ════════════════════════════════════════════════ */
.app-footer {
  margin-right: 280px;
  background: linear-gradient(135deg, #1a2332 0%, #2c3e50 100%);
  border-top: 3px solid var(--primary);
  padding: 1.25rem 2rem;
  text-align: center;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-logo {
  width: 28px;
  height: auto;
  opacity: 0.85;
  filter: brightness(0) invert(1);
  transition: var(--transition);
}

.footer-logo:hover {
  opacity: 1;
  transform: scale(1.1);
}

.footer-content span {
  color: rgba(255,255,255,0.75);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Login footer */
.login-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-light);
  font-size: 0.8rem;
}

.login-footer img {
  width: 22px;
  height: auto;
  vertical-align: middle;
  margin-left: 6px;
  opacity: 0.6;
}

@media (max-width: 768px) {
  .app-footer {
    margin-right: 0;
    padding: 1rem;
  }
  .footer-content {
    flex-direction: column;
    gap: 8px;
  }
  .footer-content span {
    font-size: 0.78rem;
  }
}
