/* ============================================================
   نظام تقييم الأداء الوظيفي - جمعية البر بالأحساء
   الأنماط الرئيسية
   ============================================================ */

:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --primary-dark: #0e3d5c;
  --secondary: #27ae60;
  --secondary-light: #2ecc71;
  --accent: #e67e22;
  --danger: #e74c3c;
  --warning: #f39c12;
  --info: #3498db;
  --success: #27ae60;

  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --text-muted: #95a5a6;
  --border: #dfe6e9;
  --border-light: #ecf0f1;

  --sidebar-width: 260px;
  --sidebar-bg: #1a252f;
  --sidebar-text: #bdc3c7;
  --sidebar-active: var(--primary-light);
  --sidebar-hover: rgba(255,255,255,0.08);

  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
}

body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary-light);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ============================================================
   App Layout
   ============================================================ */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

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

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

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: white;
  font-size: 14px;
}

.logo-text {
  font-size: 13px;
  font-weight: 700;
  color: white;
  line-height: 1.3;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 20px;
  cursor: pointer;
}

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

.user-avatar {
  width: 40px;
  height: 40px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 16px;
  flex-shrink: 0;
}

.user-details {
  overflow: hidden;
}

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

.user-role {
  font-size: 12px;
  color: var(--sidebar-text);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all var(--transition);
  font-size: 14px;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: white;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(41, 128, 185, 0.2);
  color: white;
  border-left: 3px solid var(--sidebar-active);
}

.nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 12px 0;
}

.nav-section-title {
  padding: 8px 20px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

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

.logout-btn:hover {
  background: rgba(231, 76, 60, 0.15);
  color: var(--danger);
}

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  background: var(--bg-card);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.content-area {
  flex: 1;
  padding: 24px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  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-light);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

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

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  transition: transform var(--transition);
}

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

.stat-number {
  font-size: 36px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.stat-card.primary .stat-number { color: var(--primary); }
.stat-card.success .stat-number { color: var(--success); }
.stat-card.warning .stat-number { color: var(--warning); }
.stat-card.danger .stat-number { color: var(--danger); }
.stat-card.info .stat-number { color: var(--info); }

/* ============================================================
   Tables
   ============================================================ */
.table-container {
  overflow-x: auto;
  margin: -4px;
  padding: 4px;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.table thead th {
  background: var(--bg);
  padding: 12px 16px;
  text-align: right;
  font-weight: 600;
  color: var(--text-light);
  font-size: 13px;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: rgba(0,0,0,0.02);
}

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

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-primary { background: #e8f4fd; color: var(--primary); }
.badge-success { background: #e8f8f0; color: var(--success); }
.badge-warning { background: #fef9e7; color: var(--warning); }
.badge-danger { background: #fce8e6; color: var(--danger); }
.badge-info { background: #e8f4fd; color: var(--info); }
.badge-secondary { background: #f0f0f0; color: var(--text-light); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

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

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  background: #219a52;
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #c0392b;
  color: white;
}

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

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover {
  background: var(--bg);
  color: var(--text);
}

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

.btn-block {
  display: block;
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group input[dir="ltr"] {
  text-align: left;
}

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

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success {
  background: #e8f8f0;
  color: #1a7f41;
  border: 1px solid #b8e6cc;
}

.alert-error {
  background: #fce8e6;
  color: #c0392b;
  border: 1px solid #f5c6c0;
}

.alert-warning {
  background: #fef9e7;
  color: #9a7b2c;
  border: 1px solid #f9e79f;
}

.alert-info {
  background: #e8f4fd;
  color: #1a5276;
  border: 1px solid #aed6f1;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: white;
  font-size: 22px;
  margin: 0 auto 16px;
}

.login-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.login-header p {
  font-size: 14px;
  color: var(--text-light);
}

.login-form .btn-block {
  margin-top: 24px;
  padding: 12px;
  font-size: 16px;
}

.login-hint {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  margin-top: 8px;
  line-height: 1.6;
}

.login-switch {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.login-switch a {
  color: var(--primary-light);
  font-size: 13px;
  text-decoration: none;
}

.login-switch a:hover {
  text-decoration: underline;
}

/* ============================================================
   Error Page
   ============================================================ */
.error-page {
  text-align: center;
  padding: 60px 20px;
}

.error-code {
  font-size: 80px;
  font-weight: 800;
  color: var(--primary-light);
  line-height: 1;
  margin-bottom: 16px;
}

.error-page h2 {
  font-size: 24px;
  margin-bottom: 12px;
}

.error-page p {
  color: var(--text-light);
  margin-bottom: 24px;
}

/* ============================================================
   Evaluation Sections
   ============================================================ */
.section-header {
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 700;
  font-size: 16px;
  margin-top: 24px;
}

.section-header:first-child {
  margin-top: 0;
}

.eval-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
  background: var(--bg-card);
}

.eval-item:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.eval-item-name {
  font-weight: 500;
}

.eval-item-max {
  font-size: 12px;
  color: var(--text-muted);
}

.eval-item input[type="number"] {
  width: 80px;
  text-align: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
}

.eval-item input[type="number"]:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

.eval-total {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 700;
  margin-top: 16px;
}

.eval-total .total-number {
  font-size: 28px;
}

.eval-comparison {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
  font-size: 14px;
}

.eval-comparison .score-self {
  text-align: center;
  color: var(--info);
  font-weight: 600;
}

.eval-comparison .score-manager {
  text-align: center;
  color: var(--primary);
  font-weight: 600;
}

.grade-display {
  text-align: center;
  padding: 24px;
}

.grade-score {
  font-size: 48px;
  font-weight: 800;
  color: var(--primary);
}

.grade-text {
  font-size: 24px;
  font-weight: 700;
  margin-top: 8px;
}

/* ============================================================
   Quick Actions
   ============================================================ */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
}

.quick-action:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
  text-decoration: none;
  transform: translateY(-2px);
}

.quick-action-icon {
  font-size: 24px;
}

.quick-action-text {
  font-weight: 600;
  font-size: 14px;
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.pagination a,
.pagination span {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.pagination a {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.pagination a:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  text-decoration: none;
}

.pagination .current {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

/* ============================================================
   Progress Bar
   ============================================================ */
.progress-bar {
  background: var(--border-light);
  border-radius: 10px;
  height: 12px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  border-radius: 10px;
  background: var(--success);
  transition: width 0.5s ease;
}

/* ============================================================
   Welcome Section
   ============================================================ */
.welcome-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.welcome-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.welcome-card p {
  opacity: 0.9;
  font-size: 15px;
}

/* ============================================================
   Period Banner
   ============================================================ */
.period-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-right: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.period-banner strong {
  color: var(--primary);
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  font-size: 14px;
}

/* ============================================================
   Search Bar
   ============================================================ */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.search-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary-light);
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
  .sidebar,
  .top-bar,
  .sidebar-overlay,
  .btn,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin: 0;
  }

  .content-area {
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
  }

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

  .sidebar-close {
    display: block;
  }

  .sidebar-overlay.visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }

  .sidebar-overlay {
    display: none;
  }

  .main-content {
    margin-right: 0;
  }

  .menu-toggle {
    display: block;
  }

  .content-area {
    padding: 16px;
  }

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

  .form-row {
    grid-template-columns: 1fr;
  }

  .eval-comparison {
    grid-template-columns: 1fr auto auto;
    font-size: 13px;
  }
}

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

  .card {
    padding: 16px;
  }

  .table {
    font-size: 13px;
  }

  .table thead th,
  .table tbody td {
    padding: 8px 10px;
  }
}

/* ============================================================
   جرس التنبيهات
   ============================================================ */

.notif-bell {
  position: relative;
  text-decoration: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
}
.notif-count {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  line-height: 1;
}
