/* =============================================
   نظام متابعة المهام - التصميم الرئيسي
   تصميم: Arabic RTL Dashboard - Industrial Refined
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;900&family=Tajawal:wght@300;400;500;700&display=swap');

:root {
  /* Palette - Deep Navy + Gold Accents */
  --bg-base:        #0d1117;
  --bg-surface:     #161b22;
  --bg-elevated:    #1c2230;
  --bg-hover:       #21293a;
  --border:         #2d3748;
  --border-light:   #3d4f6a;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #5a6478;

  --gold:           #d4a843;
  --gold-light:     #f0c060;
  --gold-dim:       #8a6a20;

  --success:        #22c55e;
  --warning:        #f97316;
  --danger:         #ef4444;
  --info:           #3b82f6;
  --purple:         #a855f7;
  --secondary:      #64748b;

  --sidebar-w:      260px;
  --header-h:       64px;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.3);
}

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

html { font-size: 16px; }

body {
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 13px; font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.logo-text span { display: block; color: var(--gold); font-size: 11px; font-weight: 400; }

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

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-right: 3px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-right-color: var(--border-light);
}

.nav-item.active {
  background: rgba(212,168,67,0.08);
  color: var(--gold);
  border-right-color: var(--gold);
}

.nav-item .nav-icon { font-size: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--gold-dim);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  color: var(--bg-base);
}

.user-info { flex: 1; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

.logout-btn {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: color 0.2s;
}
.logout-btn:hover { color: var(--danger); }

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

.top-bar {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.top-bar-actions { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 24px; flex: 1; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.card-body { padding: 20px; }

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

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
}

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

.stat-number {
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--accent, var(--gold));
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success  { background: rgba(34,197,94,0.15);  color: #22c55e; }
.badge-warning  { background: rgba(249,115,22,0.15); color: #f97316; }
.badge-danger   { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-info     { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-purple   { background: rgba(168,85,247,0.15); color: #a855f7; }
.badge-secondary{ background: rgba(100,116,139,0.15);color: #94a3b8; }
.badge-dark     { background: rgba(30,41,59,0.8);    color: #64748b; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gold);
  color: var(--bg-base);
  border-color: var(--gold);
}
.btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); }

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

.btn-danger {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-success {
  background: rgba(34,197,94,0.1);
  color: var(--success);
  border-color: rgba(34,197,94,0.3);
}
.btn-success:hover { background: rgba(34,197,94,0.2); }

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

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(212,168,67,0.1);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control option { background: var(--bg-elevated); }

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead tr {
  background: var(--bg-elevated);
  border-bottom: 2px solid var(--border);
}

thead th {
  padding: 12px 14px;
  text-align: right;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--text-primary);
  max-width: 280px;
}

.td-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
  display: block;
}

/* ===== FILTERS BAR ===== */
.filters-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.filter-label { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.05em; }

/* ===== ACCORDION ===== */
.accordion { display: flex; flex-direction: column; gap: 8px; }

.accordion-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.accordion-header {
  padding: 14px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.2s;
  user-select: none;
}

.accordion-header:hover { background: var(--bg-hover); }

.accordion-toggle {
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.3s;
  flex-shrink: 0;
}

.accordion-item.open .accordion-toggle { transform: rotate(90deg); color: var(--gold); }

.accordion-title { flex: 1; font-size: 14px; font-weight: 700; }

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.accordion-item.open .accordion-body { max-height: 2000px; }

.accordion-content {
  padding: 0 20px 16px;
  border-top: 1px solid var(--border);
}

/* ===== TIMELINE DOTS ===== */
.timeline { position: relative; padding-right: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  right: 9px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
  padding-right: 24px;
}

.timeline-dot {
  position: absolute;
  right: 0;
  top: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
}

.timeline-date { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.timeline-note { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding-top: 20px;
}

.page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s;
}

.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.page-btn.active { background: var(--gold); color: var(--bg-base); border-color: var(--gold); font-weight: 700; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== MODALS ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

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

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title { font-size: 17px; font-weight: 700; flex: 1; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
}
.modal-close:hover { background: var(--danger); color: white; border-color: var(--danger); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ===== FILE UPLOAD ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--gold-dim);
  background: rgba(212,168,67,0.04);
}

.upload-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.upload-text { font-size: 15px; color: var(--text-secondary); }
.upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ===== SHEET SELECTOR ===== */
.sheet-list { display: flex; flex-direction: column; gap: 8px; }

.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.sheet-item:hover { border-color: var(--border-light); }
.sheet-item.selected { border-color: var(--gold-dim); background: rgba(212,168,67,0.06); }

.sheet-checkbox {
  width: 18px; height: 18px;
  accent-color: var(--gold);
}

.sheet-name { font-size: 14px; font-weight: 600; flex: 1; }
.sheet-type-badge { font-size: 11px; }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #22c55e; }
.alert-danger   { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);  color: #ef4444; }
.alert-info     { background: rgba(59,130,246,0.1);border: 1px solid rgba(59,130,246,0.3); color: #3b82f6; }
.alert-warning  { background: rgba(249,115,22,0.1);border: 1px solid rgba(249,115,22,0.3); color: #f97316; }

/* ===== LOADING ===== */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.loading-overlay.show { display: flex; }
.loading-text { color: var(--text-secondary); font-size: 15px; }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
}

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

.login-logo .logo-icon {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  font-size: 28px;
}

.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ===== COLUMN TOGGLE ===== */
.col-toggle-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.col-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: all 0.2s;
  user-select: none;
}

.col-toggle.active {
  background: rgba(212,168,67,0.12);
  color: var(--gold);
  border-color: var(--gold-dim);
}

/* ===== APPROVED BADGE ===== */
.approved-mark {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--success);
  font-weight: 600;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-text { font-size: 15px; }
.empty-hint { font-size: 13px; margin-top: 6px; }

/* ===== UTILITY ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.fw-bold { font-weight: 700; }
.text-gold { color: var(--gold); }
.text-right { text-align: right; }
.d-none { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
