/* ================= 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; /* لمنع السكرول العرضي */
}
html {
  scroll-behavior: smooth;
}

/* ================= 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-main {
  flex: 1;
  margin-inline-start: 260px;
  padding: 30px;
  max-width: 100%;
  transition: all 0.3s ease;
}


.dashboard-sidebar {
  width: 260px;
  height: 100vh;
    display: flex;
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  z-index: 1000;
  background: var(--sidebar-bg);
  padding: 30px 20px;
  
    flex-direction: column; 
  color: var(--sidebar-text);
  transition: all 0.3s ease;
}

.sidebar-nav {
    flex-grow: 1; 
}



.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-top: 12px; /* تم التعديل */
    padding: 10px 16px;
    border-radius: 50px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    width: fit-content; /* ليكون الزر مناسباً لطول المحتوى */
}

.back-home-btn:hover {
    color: var(--primary);
    background: white;
    transform: translateX(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    /* إخفاء النص */
    .back-home-btn span {
        display: none;
    }

    /* جعل الزر مربعاً أو دائرياً بدلاً من مستطيل طويل */
    .back-home-btn {
        padding: 10px; /* تقليل الـ padding ليناسب الأيقونة فقط */
        width: 40px;   /* عرض ثابت */
        height: 40px;  /* طول ثابت */
        justify-content: center; /* توسيط الأيقونة */
        border-radius: 50%; /* تحويله لدائرة */
    }
    
    /* إزالة الـ gap لأنه لا يوجد نص */
    .back-home-btn i {
        margin: 0;
        font-size: 1.1rem; /* تكبير الأيقونة قليلاً لتكون واضحة */
    }
}
/* ================= 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: all 0.3s ease;

}
.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;
   transform: translateX(5px);
}

/* ================= 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) ================= */
/* Charts Section */


.dashboard-charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.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: 2rem; /* مساحة أكبر بين الكروت */
  margin-bottom: 2rem;
}

/* التنسيق الأساسي للكارت "البريميوم" */
.premium-card {
  background: var(--card-bg);
  padding: 2rem; /* تباعد داخلي واسع كما في الصورة */
  border-radius: 2rem; /* زوايا دائرية كبيرة جداً كما في الصورة */
  border: none; /* حذف البوردر القديم */
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05); /* ظل ناعم جداً وغير حاد */
  display: flex;
  justify-content: space-between; /* النص على اليسار والدائرة على اليمين */
  align-items: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.premium-card:hover {
  transform: translateY(-5px); /* حركة خفيفة عند الهوفر */
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08); /* ظل أعمق قليلاً */
}

/* تنسيق تفاصيل النص */
.card-details h3 {
  color: var(--text-muted);
  font-size: 0.95rem; /* أصغر قليلاً وأكثر نعومة */
  margin-bottom: 0.8rem;
  font-weight: 500;
}

.card-details .value {
  font-size: 2.2rem; /* تكبير الرقم الأساسي كما في الصورة */
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.8rem;
  letter-spacing: -0.03em; /* تقريب الحروف قليلاً */
}

.card-details .trend {
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px; /* مسافة بين النص والنسبة */
}

.trend.up {
  color: #10b981;
}

/* === تنسيقات دائرة التقدم (SVG) === */

/* حاوية الدائرة والنص */
.progress-circle-wrapper {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0; /* لمنع الدائرة من الانضغاط */
}

/* النص (النسبة المئوية) */
.progress-label {
  position: absolute;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main); /* سيأخذ اللون تلقائياً حسب المود (فاتح/غامق) */
  z-index: 10; /* لضمان بقاء النص في المقدمة */
  pointer-events: none; /* لتجنب أي تداخل في الضغط */
}

/* التأكد من أن الـ SVG خلف النص */
.progress-ring {
  position: relative;
  z-index: 1;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring__fill {
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease-in-out;
}


/* ================= TABLE & SEARCH ================= */

.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 16px; /* زيادة التباعد بين الصفوف لتبدو كبطاقات مستقلة */
  margin-top: -16px
}
.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 {
padding: 20px 20px; /* زيادة الـ Padding لتكون أكثر راحة */
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.03); /* تقليل حدة الخط */
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

/* الحواف الدائرية لكل صف */
.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: 48px;
  height: 48px;
  border-radius: 16px; /* زوايا دائرية أكبر */
  background: rgba(255, 255, 255, 0.03); /* خلفية داكنة خفيفة جداً */
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.3s;
}
.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: 8px; /* زوايا أنعم */
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-pill.active {
background: rgba(34, 197, 94, 0.1); /* شفافية خفيفة */
  color: #22c55e;
}
.status-pill.pending {
background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}
.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;
}

@media (max-width: 768px) {
    /* 1. إخفاء الجدول التقليدي */
    .premium-table thead {
        display: none; /* لا نحتاج الـ Header في الموبايل */
    }

    .premium-table, .premium-table tbody, .premium-table tr, .premium-table td {
        display: block;
        width: 100%;
    }

    /* 2. تحويل كل صف إلى "كارت" مستقل */
    .premium-table tr {
        margin-bottom: 15px;
        background: var(--bg-secondary);
        padding: 15px;
        border-radius: 16px;
        border: 1px solid var(--border);
    }

    .premium-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border: none !important; /* إلغاء الحدود الأصلية */
        background: transparent !important;
    }

    /* 3. إضافة "Labels" ديناميكية باستخدام CSS */
    .premium-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.8rem;
        text-transform: uppercase;
    }

    /* إخفاء أو تصغير العناصر الكبيرة في الموبايل */
    .progress-wrapper {
        max-width: 120px;
    }
}
/* ================= 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;
  }
}


.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;
}

.activity-item:hover .activity-status-icon {
  transform: scale(1.1);
  transition: 0.3s;
}

.skeleton {
  background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }}