/* ================= ROOT VARIABLES ================= */
:root {
  --radius-lg: 24px;
  --radius-md: 16px;
  --bg-main: #f0f5ff;
  --bg-secondary: #ffffff;
  --primary-gradient: linear-gradient(135deg, #2563eb, #3b82f6);
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --sidebar-bg: linear-gradient(180deg, #2563eb, #1e4ed8);
  --sidebar-text: #ffffff;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(37, 99, 235, 0.1);
}

body.dark {
  --bg-main: #020617;
  --bg-secondary: #0f172a;
  --primary-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);
  --primary: #6366f1;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --sidebar-bg: linear-gradient(180deg, #1e1b4b, #020617);
  --card-bg: #0f172a;
  --border: #1e293b;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* ================= GLOBAL RESET ================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  transition:
    background 0.4s,
    color 0.4s;
  overflow-x: hidden; /* لمنع السكرول العرضي */
}

/* ================= LAYOUT (Responsive Focus) ================= */
.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
}
.dashboard-main {
  animation: fadeUp 0.6s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.status-active {
  color: #22c55e;
  font-weight: 600;
}
.status-pending {
  color: #f59e0b;
  font-weight: 600;
}
.status-completed {
  color: #3b82f6;
  font-weight: 600;
}

.dashboard-sidebar {
  width: 260px;
  height: 100vh;
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  z-index: 1000;
  background: var(--sidebar-bg);
  padding: 30px 20px;
  color: var(--sidebar-text);
  transition: all 0.3s ease;
}

.dashboard-main {
  flex: 1;
  margin-inline-start: 260px;
  padding: 30px;
  max-width: 100%;
  transition: all 0.3s ease;
}

/* ================= SIDEBAR NAV ================= */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.sidebar-logo span {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #6C4DFF, #00E5FF);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}



.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 14px 20px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: 12px;
  margin-bottom: 10px;
  transition: 0.3s;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.sidebar-nav a.active {
  background: #fff;
  color: var(--primary);
  font-weight: bold;
}

/* ================= NAVBAR ================= */
.dashboard-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  background: var(--bg-secondary);
  padding: 15px 25px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  gap: 15px;
}
.navbar-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-menu img {
  width: 35px;
  height: 35px;
  border-radius: 50%;
}

.btn-cta {
  background: var(--primary-gradient);
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.3s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

/* ================= STATS & CHARTS (Responsive Grid) ================= */
.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.chart-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  /* ده أهم جزء: تحديد ارتفاع ثابت للكارت */
  height: 300px;
  display: flex;
  flex-direction: column;
}

.chart-card h3 {
  font-size: 16px;
  margin-bottom: 15px;
}

/* إجبار الكانفاس على احترام مساحة الكارت */
.chart-card canvas {
  flex-grow: 1;
  max-height: 220px !important;
  width: 100% !important;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  /* ده أهم جزء: تحديد ارتفاع ثابت للكارت */
  min-height: 150px;
  display: flex;
  flex-direction: column;
}

.card h3 {
  font-size: 16px;
  margin-bottom: 15px;
}

.card canvas {
  flex-grow: 1;
  max-height: 220px !important;
  width: 100% !important;
}

.card,
.chart-card {
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.card:hover,
.chart-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
}
/* ================= TABLE & SEARCH ================= */
/* Container الأساسي */
.dashboard-table-premium {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-top: 20px;
}

/* Header & Search Bar */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 20px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 5px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-grow: 1;
  max-width: 450px;
}

.search-icon {
  position: absolute;
  left: 20px;
  color: var(--text-muted);
}

.premium-search {
  width: 100%;
  padding: 14px 20px 14px 50px;
  background: var(--bg-main);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  color: var(--text-main);
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.premium-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
  background: var(--bg-secondary);
}

.filter-btn {
  padding: 12px 15px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  color: var(--text-main);
  transition: 0.3s;
}

/* Table Style */
.table-container {
  overflow-x: auto;
}
.premium-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 12px;
}
.premium-table th {
  padding: 15px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
}
.premium-table td {
  background: var(--bg-secondary);
  padding: 18px 15px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transition: all 0.3s ease;
}

/* الحواف الدائرية لكل صف */
.premium-table td:first-child {
  border-left: 1px solid var(--border);
  border-radius: 16px 0 0 16px;
}
.premium-table td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 16px 16px 0;
}

.premium-table tr:hover td {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.04);
  border-color: var(--primary-soft);
}

/* Project Meta & Icons */
.project-meta {
  display: flex;
  align-items: center;
  gap: 15px;
}
.project-icon {
  width: 45px;
  height: 45px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.project-icon.ai {
  background: #e0e7ff;
  color: #4338ca;
}
.project-icon.rec {
  background: #fef3c7;
  color: #b45309;
}
.project-icon.img {
  background: #dcfce7;
  color: #15803d;
}

.p-name {
  display: block;
  font-weight: 700;
  color: var(--text-main);
}
.p-category {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* User Info */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.user-info img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

/* Status Pills */
.status-pill {
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
}
.status-pill.active {
  background: #dcfce7;
  color: #166534;
}
.status-pill.pending {
  background: #fef3c7;
  color: #92400e;
}
.status-pill.completed {
  background: #e0f2fe;
  color: #075985;
}

/* Progress Bars */
.progress-wrapper {
  width: 100%;
  max-width: 180px;
}
.progress-info {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 5px;
  text-align: right;
}
.progress-track {
  height: 8px;
  background: var(--bg-main);
  border-radius: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 10px;
}
.progress-fill.success {
  background: #22c55e;
}

/* Action Group */
.action-group {
  display: flex;
  gap: 10px;
}
.action-btn {
  width: 35px;
  height: 35px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: 0.3s;
  background: var(--bg-main);
  color: var(--text-muted);
}
.action-btn.view:hover {
  background: var(--primary);
  color: white;
}
.action-btn.more:hover {
  background: #eee;
}
/* ================= MOBILE RESPONSIVE (The Magic) ================= */

@media (max-width: 992px) {
  .dashboard-sidebar {
    width: 80px;
    padding: 20px 10px;
  }
  .sidebar-logo h2,
  .sidebar-nav a span {
    display: none;
  }
  .dashboard-main {
    margin-inline-start: 80px;
    padding: 20px;
  }
  .sidebar-nav a {
    justify-content: center;
    padding: 15px;
  }
  .sidebar-nav a i {
    font-size: 20px;
    margin: 0;
  }
}

@media (max-width: 768px) {
  .dashboard-sidebar {
    width: 100%;
    height: 60px;
    top: auto;
    bottom: 0; /* تحويل السايد بار لشريط سفلي للموبايل */
    flex-direction: row;
    padding: 0;
    justify-content: center;
  }
  .sidebar-logo {
    display: none;
  }
  .sidebar-nav {
    display: flex;
    width: 100%;
    justify-content: space-around;
    height: 100%;
  }
  .sidebar-nav a {
    margin: 0;
    height: 100%;
    border-radius: 0;
    background: transparent !important;
  }
  .sidebar-nav a.active {
    color: #fff;
    border-top: 3px solid #fff;
  }

  .dashboard-main {
    margin-inline-start: 0;
    padding: 15px;
    padding-bottom: 80px; /* مساحة عشان السايد بار السفلي */
  }

  .dashboard-navbar {
    flex-direction: column;
    text-align: center;
  }
  .dashboard-navbar h2 {
    font-size: 18px;
  }

  .dashboard-charts {
    grid-template-columns: 1fr;
  }
  .chart-card {
    min-height: 280px;
  }
}

@media (max-width: 480px) {
  .dashboard-cards {
    grid-template-columns: 1fr;
  }
  .btn-cta {
    padding: 6px 10px;
    font-size: 12px;
  }
  #projectSearch {
    font-size: 13px;
  }
}

.back-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  padding: 8px 16px;
  border-radius: 50px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.back-home-btn i {
  font-size: 0.8rem;
}

.back-home-btn:hover {
  color: var(--primary);
  background: white;
  transform: translateX(-5px); /* حركة خفيفة لليسار عند الهوفر */
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}


.dashboard-activity-premium {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-top: 30px;
}

.btn-outline {
    padding: 8px 16px;
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

/* Timeline Logic */
.activity-timeline {
    position: relative;
    padding-left: 20px;
    margin-top: 20px;
}

/* الخط الواصل بين النشاطات */
.activity-timeline::before {
    content: '';
    position: absolute;
    left: 40px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.activity-item {
    position: relative;
    display: flex;
    gap: 25px;
    margin-bottom: 30px;
    z-index: 1;
}

.activity-status-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 2px solid var(--border);
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* ألوان مختلفة لكل نوع نشاط */
.activity-status-icon.upload { color: #3b82f6; border-color: #3b82f6; background: #eff6ff; }
.activity-status-icon.comment { color: #f59e0b; border-color: #f59e0b; background: #fffbeb; }
.activity-status-icon.success { color: #10b981; border-color: #10b981; background: #ecfdf5; }

.activity-content {
    flex-grow: 1;
    padding-bottom: 15px;
}

.activity-info p {
    font-size: 0.95rem;
    color: var(--text-main);
    margin-bottom: 5px;
}

.highlight {
    font-weight: 700;
    color: var(--primary);
}

.activity-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* تفاصيل إضافية (الصور والاقتباسات) */
.activity-assets {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.asset-preview {
    width: 50px;
    height: 50px;
    background: var(--bg-main);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.activity-quote {
    margin-top: 10px;
    padding: 10px 15px;
    background: var(--bg-main);
    border-left: 4px solid var(--border);
    border-radius: 4px;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.status-tag {
    background: #dcfce7;
    color: #166534;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}