/* ========== متغيرات الثيم (من theme.css) ========== */
:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1e40af;
  --color-primary-light: #3b82f6;
  --color-primary-lighter: #60a5fa;
  --color-primary-lightest: #dbeafe;
  --color-secondary: #64748b;
  --color-secondary-dark: #475569;
  --color-secondary-light: #94a3b8;
  --color-accent: #8b5cf6;
  --color-accent-light: #a78bfa;
  --color-success: #10b981;
  --color-success-light: #34d399;
  --color-success-bg: #d1fae5;
  --color-warning: #f59e0b;
  --color-warning-light: #fbbf24;
  --color-warning-bg: #fef3c7;
  --color-error: #ef4444;
  --color-error-light: #f87171;
  --color-error-bg: #fee2e2;
  --color-info: #3b82f6;
  --color-info-light: #60a5fa;
  --color-info-bg: #dbeafe;
  --color-text-primary: #1f2937;
  --color-text-secondary: #6b7280;
  --color-text-tertiary: #9ca3af;
  --color-text-disabled: #d1d5db;
  --color-text-inverse: #ffffff;
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f9fafb;
  --color-bg-tertiary: #f3f4f6;
  --color-bg-elevation: #ffffff;
  --color-bg-overlay: rgba(0, 0, 0, 0.5);
  --color-border: #e5e7eb;
  --color-border-light: #f3f4f6;
  --color-border-dark: #d1d5db;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  --spacing-3xl: 4rem;
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;
  --font-size-5xl: 3rem;
  --line-height-tight: 1.25;
  --transition-fast: 150ms ease-in-out;
  --transition-base: 200ms ease-in-out;
  --transition-slow: 300ms ease-in-out;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ========== الأنماط الأساسية ========== */
body {
  font-family: var(--font-family-base);
  color: var(--color-text-primary);
  background-color: var(--color-bg-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}
h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }

/* ========== الشريط الجانبي ========== */
.sidebar-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 500;
  border-radius: 0 24px 24px 0;
  margin-right: 8px;
  transition: all var(--transition-base);
  position: relative;
}
.sidebar-item:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  transform: translateX(2px);
}
.sidebar-item.active {
  background: var(--color-primary-lightest);
  color: var(--color-primary);
  font-weight: 600;
}
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

/* ========== عناصر الملفات ========== */
.file-item {
  transition: all var(--transition-base);
  border-radius: var(--radius-md);
}
.file-item:hover {
  background-color: var(--color-bg-secondary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ========== رفع الملفات ========== */
.upload-progress {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--color-bg-elevation);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 300px;
  z-index: var(--z-modal);
  border: 1px solid var(--color-border);
}
.upload-item { margin-bottom: var(--spacing-sm); }
.upload-item:last-child { margin-bottom: 0; }
.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: var(--spacing-sm);
}
.progress-fill {
  height: 100%;
  background-color: var(--color-primary);
  transition: width 0.3s ease;
}

/* ========== النوافذ المنبثقة ========== */
.modal {
  display: none;
  position: fixed;
  z-index: var(--z-modal);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: var(--color-bg-overlay);
  backdrop-filter: blur(4px);
}
.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background-color: var(--color-bg-elevation);
  padding: var(--spacing-xl);
  border-radius: var(--radius-xl);
  max-width: 90%;
  max-height: 90%;
  overflow: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== منطقة السحب والإفلات المحسّنة ========== */
.drop-zone {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: all var(--transition-slow);
}

.drop-zone.active {
  display: flex;
  pointer-events: all;
}

/* خلفية متدرجة متحركة */
.drop-zone-gradient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(37, 99, 235, 0.15) 0%, rgba(37, 99, 235, 0.05) 70%, transparent 100%);
  animation: dropZonePulse 2s ease-in-out infinite;
  pointer-events: none;
}

.drop-zone.active .drop-zone-gradient {
  animation: dropZonePulseActive 1.5s ease-in-out infinite;
}

/* محتوى منطقة السحب */
.drop-zone-content {
  position: relative;
  z-index: 2;
  background: var(--color-bg-elevation);
  padding: var(--spacing-3xl) var(--spacing-2xl);
  border-radius: var(--radius-xl);
  text-align: center;
  box-shadow: 0 20px 60px -12px rgba(37, 99, 235, 0.3);
  border: 2px dashed var(--color-primary);
  backdrop-filter: blur(10px);
  max-width: 500px;
  animation: slideUp 0.5s ease-out;
  transform-origin: center;
  transition: all var(--transition-slow);
}

.drop-zone.active .drop-zone-content {
  border-color: var(--color-primary-light);
  background: var(--color-bg-elevation);
  box-shadow: 0 30px 80px -12px rgba(37, 99, 235, 0.4);
  transform: scale(1.02);
}

/* أيقونة السحب والإفلات */
.drop-zone-icon-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto var(--spacing-lg);
}

.drop-zone-icon {
  width: 100px;
  height: 100px;
  color: var(--color-primary);
  animation: dropZoneIconFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(37, 99, 235, 0.3));
  transition: all var(--transition-base);
}

.drop-zone.active .drop-zone-icon {
  animation: dropZoneIconBounce 0.6s ease-in-out;
  filter: drop-shadow(0 8px 20px rgba(37, 99, 235, 0.5));
}

.drop-zone-icon-secondary {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 40px;
  height: 40px;
  color: var(--color-success);
  opacity: 0;
  animation: dropZoneCheckIn 0.5s ease-out forwards;
  animation-delay: 0.3s;
}

.drop-zone.active .drop-zone-icon-secondary {
  animation: dropZoneCheckBounce 0.6s ease-out 0.2s forwards;
}

/* النصوص */
.drop-zone-title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--spacing-sm);
  animation: slideUp 0.5s ease-out 0.1s backwards;
}

.drop-zone-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-sm);
  animation: slideUp 0.5s ease-out 0.2s backwards;
}

.drop-zone-info {
  color: var(--color-text-tertiary);
  font-size: var(--font-size-base);
  animation: slideUp 0.5s ease-out 0.3s backwards;
}

/* زر Browse */
.drop-zone-button {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  animation: slideUp 0.5s ease-out 0.4s backwards;
}

.drop-zone-button:hover {
  background: var(--color-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.4);
}

.drop-zone-button:active {
  transform: translateY(0);
}

/* الحركات والتأثيرات */
@keyframes dropZonePulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

@keyframes dropZonePulseActive {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

@keyframes dropZoneIconFloat {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-15px) scale(1.05); }
}

@keyframes dropZoneIconBounce {
  0% { transform: scale(0.8) rotate(0deg); }
  50% { transform: scale(1.1) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes dropZoneCheckIn {
  0% { 
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes dropZoneCheckBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* ========== Skeleton / التحميل ========== */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg-tertiary) 25%, var(--color-bg-secondary) 50%, var(--color-bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 1em; border-radius: var(--radius-sm); margin-bottom: var(--spacing-xs); }
.skeleton-avatar { width: 40px; height: 40px; border-radius: var(--radius-full); }
.skeleton-card { padding: var(--spacing-md); border-radius: var(--radius-lg); border: 1px solid var(--color-border); }

/* ========== الحالة الفارغة ========== */
.empty-state {
  text-align: center;
  padding: var(--spacing-3xl) var(--spacing-lg);
  color: var(--color-text-secondary);
}
.empty-state-icon { width: 80px; height: 80px; margin: 0 auto var(--spacing-lg); opacity: 0.5; }
.empty-state-title { font-size: var(--font-size-xl); font-weight: 600; color: var(--color-text-primary); margin-bottom: var(--spacing-sm); }
.empty-state-description { font-size: var(--font-size-base); color: var(--color-text-secondary); margin-bottom: var(--spacing-lg); }

/* ========== رسائل الخطأ والنجاح ========== */
.error-message {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-light);
  color: var(--color-error);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}
.error-message svg { width: 20px; height: 20px; flex-shrink: 0; }
.success-message {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-light);
  color: var(--color-success);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}
.success-message svg { width: 20px; height: 20px; flex-shrink: 0; }

/* للعناصر الديناميكية (مثل نافذة مشاركة الرابط) */
.bg-success-bg { background-color: var(--color-success-bg); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: var(--spacing-xl); right: var(--spacing-xl);
  background: var(--color-bg-elevation);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
  z-index: var(--z-tooltip);
  min-width: 300px; max-width: 400px;
}
.toast-success { border-left: 4px solid var(--color-success); }
.toast-error { border-left: 4px solid var(--color-error); }
.toast-warning { border-left: 4px solid var(--color-warning); }
.toast-info { border-left: 4px solid var(--color-info); }

/* ========== إخفاء شريط التمرير ========== */
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }

/* ========== حقول النماذج ========== */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="file"], select, textarea {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-family: var(--font-family-base);
  transition: all var(--transition-base);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-lightest);
}
input::placeholder, textarea::placeholder { color: var(--color-text-tertiary); }

/* ========== الأزرار ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  gap: var(--spacing-xs);
}
.btn-primary { background: var(--color-primary); color: var(--color-text-inverse); }
.btn-primary:hover { background: var(--color-primary-dark); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-secondary { background: var(--color-bg-tertiary); color: var(--color-text-primary); }
.btn-secondary:hover { background: var(--color-border-dark); }
.btn-danger { background: var(--color-error); color: var(--color-text-inverse); }
.btn-danger:hover { background: var(--color-error-light); }

/* ========== البطاقات ========== */
.card {
  background: var(--color-bg-elevation);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  transition: all var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* ========== صفوف الملفات وقوائم/شبكة ========== */
.file-row {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: all var(--transition-base);
}
.file-row:hover { background: var(--color-bg-secondary); }
.file-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
}
.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}
.view-list { display: flex; flex-direction: column; }
.view-list .content-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}
.view-grid .content-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: var(--color-bg-elevation);
  transition: all var(--transition-base);
}
.view-grid .content-item:hover { box-shadow: var(--shadow-md); }
.view-grid .content-item .file-icon {
  width: 100%;
  height: 120px;
  margin-bottom: 0.5rem;
}
.view-grid .content-item .file-icon svg { width: 64px; height: 64px; }
.view-grid .content-item .file-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }
.view-toggle-btn.active { background: var(--color-primary-lightest); }
.view-toggle-btn.active svg { color: var(--color-primary); }

/* ========== استجابة الشاشات ========== */
@media (max-width: 640px) {
  .sidebar-item { padding: 10px 16px; font-size: var(--font-size-xs); }
  .content-item { padding: var(--spacing-sm); }
  .modal-content { padding: var(--spacing-md); max-width: 95%; margin: var(--spacing-md); }
  .toast { bottom: var(--spacing-md); right: var(--spacing-md); left: var(--spacing-md); min-width: auto; max-width: none; }
  .empty-state { padding: var(--spacing-xl) var(--spacing-md); }
  .empty-state-icon { width: 60px; height: 60px; }
  .card { padding: var(--spacing-sm); }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .sidebar-item { padding: 10px 18px; }
  .modal-content { max-width: 80%; }
}
@media (min-width: 1025px) {
  .modal-content { max-width: 600px; }
}

/* ========== تحسينات حقل البحث ========== */
.drive-search-wrapper {
  position: relative;
}

.drive-search {
  position: relative;
  overflow: hidden;
}

/* التأثير المتدرج عند التركيز */
.drive-search::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(37, 99, 235, 0.1),
    transparent
  );
  transition: left 0.5s ease;
  pointer-events: none;
}

.drive-search-wrapper:focus-within .drive-search::before {
  left: 100%;
}

/* زر المسح - تأثيرات متقدمة */
.drive-search-clear {
  position: relative;
  z-index: 10;
}

.drive-search-clear:hover {
  transform: scale(1.1) rotate(90deg);
}

.drive-search-clear:active {
  transform: scale(0.95);
}

/* حقل البحث - تحسينات */
.drive-search-input {
  letter-spacing: 0.3px;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.drive-search-input:focus {
  letter-spacing: 0.5px;
}

/* مؤشر التحميل */
.drive-search-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: translateY(-50%) rotate(0deg);
  }
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* تحسين على الهاتف الذكي */
@media (max-width: 640px) {
  .drive-search {
    padding: 0 8px;
  }
  .drive-search-clear {
    padding: 8px;
  }
}

/* تأثير النبض عند التركيز */
@keyframes pulse-border {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(37, 99, 235, 0);
  }
}

.drive-search-wrapper:focus-within .drive-search {
  animation: none;
}
