/* ============================================
   MAIN STYLESHEET
   Theme-driven via CSS Custom Properties
   ============================================ */

/* --- CSS Custom Properties (defaults for original-purple) --- */
:root {
  --bg: #FFFFFF;
  --bg-secondary: #F9FAFB;
  --accent: #8B5CF6;
  --accent-light: #A78BFA;
  --accent-dark: #7C3AED;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(139, 92, 246, 0.15);
  --glass-hover: rgba(139, 92, 246, 0.08);
  --text: #1F2937;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --particle-color: 139, 92, 246;
  --card-bg: rgba(255, 255, 255, 0.85);
  --input-bg: rgba(255, 255, 255, 0.7);
  --shadow: rgba(139, 92, 246, 0.12);
  --shadow-lg: rgba(139, 92, 246, 0.18);
  --badge-bg: linear-gradient(135deg, #8B5CF6, #7C3AED);
  --scrollbar: #A78BFA;
  --selection: rgba(139, 92, 246, 0.2);
  --blur: 20px;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Cairo', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* Selection */
::selection { background: var(--selection); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }

/* ============================================
   PARTICLE CANVAS
   ============================================ */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ============================================
   GLASS CARD
   ============================================ */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px var(--shadow);
  transition: var(--transition);
}

.glass-card:hover {
  box-shadow: 0 16px 48px var(--shadow-lg);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  box-shadow: 0 4px 15px var(--shadow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow-lg);
}

.btn-outline {
  border: 2px solid var(--glass-border);
  color: var(--accent);
  background: transparent;
}

.btn-outline:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-danger {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================
   FORMS
   ============================================ */
.form-group {
  margin-bottom: 16px;
  flex: 1;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-xs);
  background: var(--input-bg);
  color: var(--text);
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glass-hover);
}

.form-row { display: flex; gap: 16px; }

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 8px 0;
  font-weight: 500;
}

.toggle-switch {
  width: 44px;
  height: 24px;
  -webkit-appearance: none;
  appearance: none;
  background: #d1d5db;
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.toggle-switch::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.toggle-switch:checked { background: var(--accent); }
.toggle-switch:checked::before { transform: translateX(20px); }

.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #DC2626;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.password-wrapper { position: relative; }

.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  padding: 4px;
}

/* ============================================
   PAGE VISIBILITY
   ============================================ */
.page { min-height: 100vh; }

/* ============================================
   PUBLIC PAGE - PORTFOLIO
   ============================================ */
.portfolio-container {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 20px 100px;
}

/* Profile */
.profile-section { text-align: center; margin-bottom: 40px; }
.profile-card { padding: 40px 30px; }

.avatar-wrapper {
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--accent-light);
  box-shadow: 0 0 0 4px var(--glass-hover), 0 8px 32px var(--shadow);
}

.avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-dark));
}

.profile-name { font-size: 1.8rem; font-weight: 800; margin-bottom: 4px; }
.profile-title { font-size: 1rem; color: var(--accent); font-weight: 600; margin-bottom: 12px; }
.profile-bio { font-size: 0.95rem; color: var(--text-muted); line-height: 1.7; max-width: 480px; margin: 0 auto; }

/* Section titles */
.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 20px;
}

.section-title::after {
  content: '';
  display: block;
  width: 40px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
  margin: 8px auto 0;
}

/* Links Grid */
.links-section { margin-bottom: 48px; }
.links-grid { display: grid; gap: 14px; }

.link-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.link-card:hover { transform: translateY(-3px); }

.link-card-img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.link-card-img-placeholder {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
}

.link-card-info { flex: 1; min-width: 0; }

.link-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.link-card-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--badge-bg);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.link-card-clicks {
  font-size: 0.7rem;
  color: var(--text-light);
}

.link-card-arrow {
  color: var(--text-light);
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: var(--transition);
}

.link-card:hover .link-card-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* Projects */
.projects-section { margin-bottom: 48px; }

.project-filters {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-btn {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 2px solid var(--glass-border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn.active,
.filter-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.projects-grid { display: grid; gap: 20px; }

.project-card { padding: 0; overflow: hidden; }
.project-card:hover { transform: translateY(-4px); }

.project-gallery {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: linear-gradient(135deg, var(--bg-secondary), var(--glass-bg));
  cursor: pointer;
}

.project-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.project-card:hover .project-gallery img { transform: scale(1.05); }

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1F2937;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  z-index: 2;
}

.gallery-nav:hover { background: var(--accent); color: white; }
.gallery-prev { left: 10px; }
.gallery-next { right: 10px; }

.gallery-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}

.gallery-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: var(--transition);
}

.gallery-dot.active { background: white; transform: scale(1.3); }

.project-body { padding: 20px; }
.project-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.project-desc { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; }

.project-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.project-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--glass-hover);
  color: var(--accent);
}

.project-links { display: flex; gap: 10px; }

.project-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--glass-hover);
  color: var(--accent);
  transition: var(--transition);
}

.project-link-btn:hover { background: var(--accent); color: white; }

/* Code snippets */
.code-snippet { margin: 12px 0; border-radius: var(--radius-xs); overflow: hidden; }

.code-snippet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #1e1e2e;
  font-size: 0.75rem;
  color: #9ca3af;
}

.copy-code-btn {
  color: var(--accent-light);
  font-size: 0.75rem;
  cursor: pointer;
  background: none;
  border: none;
  transition: var(--transition);
}

.copy-code-btn:hover { color: white; }

.code-snippet pre { margin: 0; border-radius: 0; }
.code-snippet pre code { font-size: 0.82rem !important; line-height: 1.5 !important; }

/* Social Bar */
.social-section { margin-bottom: 40px; }

.social-bar { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }

.social-icon-link {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: var(--transition);
}

.social-icon-link:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-3px);
}

/* Footer */
.portfolio-footer { text-align: center; padding-top: 20px; }

.footer-card { padding: 24px; margin-bottom: 16px; }
.footer-card p { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 8px; }

.footer-email {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  transition: var(--transition);
}

.footer-email:hover { opacity: 0.8; }
.copyright { font-size: 0.8rem; color: var(--text-light); }

/* Public language toggle */
.public-lang-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px var(--shadow);
}

.public-lang-toggle:hover {
  background: var(--accent);
  color: white;
}

html[dir="rtl"] .public-lang-toggle { right: auto; left: 16px; }

/* ============================================
   LIGHTBOX
   ============================================ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox img { max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: 8px; }

.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute;
  color: white;
  cursor: pointer;
  background: rgba(255,255,255,0.1);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  border: none;
}

.lightbox-close:hover, .lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,0.25); }
.lightbox-close { top: 20px; right: 20px; font-size: 1.5rem; z-index: 2; }
.lightbox-prev { left: 20px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; }
.lightbox-next { right: 20px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

html[dir="rtl"] .toast-container { right: auto; left: 20px; }

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-xs);
  background: var(--card-bg);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  box-shadow: 0 16px 48px var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
  max-width: 360px;
  color: var(--text);
}

.toast-success { border-left: 4px solid #10B981; }
.toast-success .toast-icon { color: #10B981; }
.toast-error { border-left: 4px solid #EF4444; }
.toast-error .toast-icon { color: #EF4444; }
.toast-info { border-left: 4px solid var(--accent); }
.toast-info .toast-icon { color: var(--accent); }

html[dir="rtl"] .toast-success { border-left: none; border-right: 4px solid #10B981; }
html[dir="rtl"] .toast-error { border-left: none; border-right: 4px solid #EF4444; }
html[dir="rtl"] .toast-info { border-left: none; border-right: 4px solid var(--accent); }

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

/* ============================================
   CONFIRM DIALOG
   ============================================ */
.confirm-card {
  text-align: center;
  padding: 30px;
  max-width: 400px;
  width: 90%;
}

.confirm-icon { font-size: 2.5rem; color: #F59E0B; margin-bottom: 16px; }
.confirm-card h3 { margin-bottom: 10px; }
.confirm-card p { color: var(--text-muted); margin-bottom: 24px; font-size: 0.9rem; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
  .portfolio-container { padding: 24px 16px 80px; }
  .profile-card { padding: 30px 20px; }
  .avatar-wrapper { width: 100px; height: 100px; }
  .profile-name { font-size: 1.5rem; }
  .form-row { flex-direction: column; gap: 0; }
  .link-card { padding: 14px; }
  .link-card-img { width: 40px; height: 40px; }
  .toast-container { left: 16px; right: 16px; }
  .toast { max-width: 100%; }
}

/* RTL Support */
html[dir="rtl"] body { font-family: 'Cairo', 'Inter', 'Segoe UI', Tahoma, Arial, sans-serif; }
html[dir="rtl"] .link-card { flex-direction: row-reverse; }
html[dir="rtl"] .link-card-arrow { transform: scaleX(-1); }
html[dir="rtl"] .link-card:hover .link-card-arrow { transform: scaleX(-1) translateX(3px); }

/* Fade animation */
.fade-in { animation: fadeIn 0.4s ease; }
.hidden { display: none !important; }

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