/* Custom styles for Project Management System */
@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;600;700;800&display=swap');

/* Fix: ensure .hidden always works regardless of ID/element specificity */
.hidden { display: none !important; }

* {
  box-sizing: border-box;
}

body {
  font-family: 'Rubik', 'Segoe UI', Tahoma, Arial, sans-serif;
  direction: rtl;
}

/* Sidebar active state - BordUp style */
.nav-btn.active {
  background: #eef2ff !important;
  color: #4f46e5 !important;
  font-weight: 700;
}

.nav-btn.active span:first-child {
  background: #e0e7ff !important;
}

.nav-btn.active i {
  color: #4f46e5 !important;
}

/* Active nav - add left accent indicator */
.nav-btn.active-nav {
  background: #eef2ff !important;
  color: #4f46e5 !important;
}

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

/* Card hover */
.stat-card {
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

/* Progress bar */
.progress-bar {
  transition: width 0.8s ease-in-out;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-planning { background: #dbeafe; color: #1e40af; }
.badge-delayed { background: #fee2e2; color: #991b1b; }
.badge-completed { background: #f0fdf4; color: #15803d; }
.badge-on-hold { background: #fef9c3; color: #854d0e; }
.badge-canceled { background: #f1f5f9; color: #475569; }

.badge-high { background: #fee2e2; color: #991b1b; }
.badge-medium { background: #fef9c3; color: #854d0e; }
.badge-low { background: #dcfce7; color: #166534; }

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 12px 16px;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  color: #374151;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

/* Gantt Chart */
.gantt-container {
  overflow-x: auto;
  overflow-y: visible;
}

.gantt-bar {
  border-radius: 4px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: filter 0.2s;
}

.gantt-bar:hover {
  filter: brightness(1.1);
}

.gantt-progress {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  background: rgba(0,0,0,0.2);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Toast */
.toast {
  padding: 12px 20px;
  border-radius: 12px;
  color: white;
  font-weight: 500;
  font-size: 0.875rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  animation: slideInRight 0.3s ease;
  min-width: 250px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #2563eb; }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Form styles */
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.875rem;
  color: #1f2937;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  direction: rtl;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

select.form-input {
  cursor: pointer;
}

/* Tabs */
.tab-btn {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.tab-btn.active {
  color: #1d4ed8;
  border-bottom-color: #1d4ed8;
}

.tab-btn:hover {
  color: #1d4ed8;
}

/* Priority indicator */
.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.priority-high { background: #ef4444; }
.priority-medium { background: #f59e0b; }
.priority-low { background: #22c55e; }

/* Influence/Interest matrix cell */
.matrix-cell {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
}

/* Loading spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Notification item */
.notif-item {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #f1f5f9;
  margin-bottom: 6px;
  transition: background 0.2s;
}

.notif-item:hover {
  background: #f8fafc;
}

.notif-item.unread {
  background: #eff6ff;
  border-color: #bfdbfe;
}

/* ===== Task Row Highlight (from notification navigation) ===== */
@keyframes taskHighlightPulse {
  0%   { background-color: #fef9c3; box-shadow: 0 0 0 3px #fbbf24; }
  40%  { background-color: #fef08a; box-shadow: 0 0 0 5px #f59e0b; }
  70%  { background-color: #fef9c3; box-shadow: 0 0 0 3px #fbbf24; }
  100% { background-color: #fef9c3; box-shadow: 0 0 0 3px #fbbf24; }
}

tr.task-highlight {
  animation: taskHighlightPulse 1.4s ease-in-out 2;
  background-color: #fef9c3 !important;
  box-shadow: 0 0 0 3px #fbbf24;
  border-radius: 8px;
  position: relative;
  z-index: 1;
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
  cursor: default;
}

tr.task-highlight td:first-child {
  border-right: 4px solid #f59e0b;
}

tr.task-highlight:hover {
  background-color: transparent !important;
  box-shadow: none !important;
  border-right: none;
  animation: none;
}

/* Responsive sidebar */
@media (max-width: 1023px) {
  #sidebar {
    transform: translateX(100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
}

/* ── بطاقات الأسبوع ── */
#curr-week-tasks-container .divide-y > div:hover {
  background-color: #eef2ff;
}

#open-risks-list > div {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#open-risks-list > div:hover {
  transform: translateY(-1px);
}

/* تبويبات الأسبوع الحالي - حد سفلي متحرك */
.cwt-pill {
  border-bottom: 2px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}
.cwt-pill.cwt-active-blue   { border-bottom-color: #2563eb; background: #dbeafe; }
.cwt-pill.cwt-active-amber  { border-bottom-color: #d97706; background: #fef3c7; }
.cwt-pill.cwt-active-green  { border-bottom-color: #059669; background: #d1fae5; }

/* تبويبات الأسبوع الماضي */
.lwt-pill {
  transition: all 0.2s ease;
  border-radius: 12px;
}
.lwt-pill:hover {
  transform: translateY(-1px);
}

/* بطاقات مهام الأسبوع الماضي */
#last-week-tasks-container .rounded-2xl {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Chart container */
.chart-container {
  position: relative;
  height: 250px;
}

/* أزرار فلتر المشاريع */
.filter-btn {
  transition: all 0.15s ease;
}
.filter-btn:hover {
  transform: translateY(-1px);
}
.filter-btn-active {
  background: #1d4ed8;
  color: white;
  box-shadow: 0 2px 6px rgba(29,78,216,0.35);
}

/* مخطط الإنجاز الأفقي — يتمدد حسب عدد المشاريع */
.chart-container.completion-chart-wrap {
  height: auto;
  min-height: 200px;
}

/* Risk matrix */
.risk-cell {
  padding: 8px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
}

/* Avatar colors */
.avatar-blue { background: #1d4ed8; }
.avatar-green { background: #059669; }
.avatar-purple { background: #7c3aed; }
.avatar-orange { background: #d97706; }
.avatar-red { background: #dc2626; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Project card */
.project-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid #e2e8f0;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
  border-color: #bfdbfe;
}

/* Sticky header for tables */
.sticky-header th {
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Page transition */
#page-content {
  animation: pageIn 0.3s ease;
}

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

/* Print styles */
@media print {
  #sidebar, header, #toast-container, #modals { display: none !important; }
  .lg\:mr-\[252px\] { margin-right: 0 !important; }
  .no-print { display: none !important; }
}

/* ===== Dark Mode ===== */
html.dark-mode {
  --bg-primary:   #0f172a;
  --bg-secondary: #1e293b;
  --bg-card:      #1e293b;
  --border-color: #334155;
  --text-primary: #f1f5f9;
  --text-secondary:#94a3b8;
}

html.dark-mode body {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
}

html.dark-mode #main-content,
html.dark-mode main {
  background-color: var(--bg-primary) !important;
}

html.dark-mode .bg-white,
html.dark-mode .bg-gray-50 {
  background-color: var(--bg-card) !important;
  border-color: var(--border-color) !important;
}

html.dark-mode .bg-gray-100 {
  background-color: #263045 !important;
}

html.dark-mode .text-gray-800,
html.dark-mode .text-gray-900 {
  color: var(--text-primary) !important;
}

html.dark-mode .text-gray-600,
html.dark-mode .text-gray-500,
html.dark-mode .text-gray-400 {
  color: var(--text-secondary) !important;
}

html.dark-mode .border-gray-100,
html.dark-mode .border-gray-200,
html.dark-mode .border-gray-300 {
  border-color: var(--border-color) !important;
}

html.dark-mode .shadow-sm,
html.dark-mode .shadow {
  box-shadow: 0 1px 3px rgba(0,0,0,.4) !important;
}

html.dark-mode input.form-input,
html.dark-mode select.form-input,
html.dark-mode textarea.form-input {
  background-color: #263045 !important;
  border-color: #475569 !important;
  color: var(--text-primary) !important;
}

html.dark-mode .data-table th {
  background-color: #263045 !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
}

html.dark-mode .data-table td {
  border-color: var(--border-color) !important;
}

html.dark-mode .data-table tr:hover {
  background-color: #263045 !important;
}

html.dark-mode .hover\:bg-gray-50:hover,
html.dark-mode .hover\:bg-gray-100:hover {
  background-color: #263045 !important;
}

html.dark-mode .stat-card:hover {
  box-shadow: 0 4px 15px rgba(0,0,0,.4) !important;
}

/* ===== كثافة العرض (Density) ===== */
/* مضغوط */
html[data-density='compact'] main {
  padding: 0.75rem !important;
}
html[data-density='compact'] .stat-card,
html[data-density='compact'] .bg-white.rounded-2xl {
  padding: 0.75rem !important;
}
html[data-density='compact'] .data-table th,
html[data-density='compact'] .data-table td {
  padding: 0.4rem 0.75rem !important;
  font-size: 0.8rem !important;
}
html[data-density='compact'] .grid.gap-4 { gap: 0.5rem !important; }
html[data-density='compact'] .gap-6      { gap: 0.75rem !important; }

/* واسع */
html[data-density='spacious'] main {
  padding: 2rem !important;
}
html[data-density='spacious'] .stat-card,
html[data-density='spacious'] .bg-white.rounded-2xl {
  padding: 2rem !important;
}
html[data-density='spacious'] .data-table th,
html[data-density='spacious'] .data-table td {
  padding: 1rem 1.5rem !important;
  font-size: 0.95rem !important;
}
html[data-density='spacious'] .grid.gap-4 { gap: 1.5rem !important; }
html[data-density='spacious'] .gap-6      { gap: 2rem !important; }
