/* ==========================================================================
   Mostafa Salah Portfolio - Pure CSS Stylesheet
   Self-contained, high-performance styling with RTL & LTR support
   ========================================================================== */

:root {
  /* Dark Mode Default Theme */
  --bg-primary: #030712;
  --bg-secondary: #0b1329;
  --bg-surface: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-glass-header: rgba(3, 7, 18, 0.88);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-card: rgba(255, 255, 255, 0.1);
  --border-emerald: rgba(16, 185, 129, 0.3);
  --border-cyan: rgba(6, 182, 212, 0.3);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-heading: #ffffff;
  --accent-emerald: #10b981;
  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-amber: #f59e0b;
  --shadow-card: rgba(0, 0, 0, 0.7);
  --grid-line: rgba(255, 255, 255, 0.03);
  --badge-bg: rgba(15, 23, 42, 0.8);
}

/* Light Mode Theme */
html.light {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-glass-header: rgba(255, 255, 255, 0.88);
  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-card: rgba(15, 23, 42, 0.12);
  --border-emerald: rgba(16, 185, 129, 0.4);
  --border-cyan: rgba(2, 132, 199, 0.4);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-heading: #020617;
  --accent-emerald: #059669;
  --accent-cyan: #0284c7;
  --accent-indigo: #4f46e5;
  --accent-amber: #d97706;
  --shadow-card: rgba(15, 23, 42, 0.08);
  --grid-line: rgba(15, 23, 42, 0.04);
  --badge-bg: rgba(241, 245, 249, 0.9);
}

/* Global Reset & Base Setup */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* Arabic typography overrides */
[dir="rtl"] {
  font-family: 'Cairo', 'Plus Jakarta Sans', system-ui, sans-serif;
}

[dir="rtl"] .font-mono,
.font-mono {
  font-family: 'JetBrains Mono', monospace;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #020617;
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Background Gradients & Mesh */
.bg-grid-pattern {
  background-size: 40px 40px;
  background-image: 
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
}

.radial-glow-emerald {
  background: radial-gradient(circle 500px at 50% 10%, rgba(16, 185, 129, 0.12), transparent 70%);
}

.radial-glow-cyan {
  background: radial-gradient(circle 500px at 80% 60%, rgba(6, 182, 212, 0.08), transparent 70%);
}

html.light .radial-glow-emerald {
  background: radial-gradient(circle 500px at 50% 10%, rgba(16, 185, 129, 0.08), transparent 70%);
}

html.light .radial-glow-cyan {
  background: radial-gradient(circle 500px at 80% 60%, rgba(2, 132, 199, 0.07), transparent 70%);
}

/* Glassmorphism Cards */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  box-shadow: 0 4px 20px -2px var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-emerald);
  box-shadow: 0 12px 30px -10px rgba(16, 185, 129, 0.18);
}

header,
.glass-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 50 !important;
  background: var(--bg-glass-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  overflow: visible !important;
  padding: 0 !important;
  margin: 0 !important;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* الحاوية الرئيسية للهيدر (Header Wrapper) */
.glass-header-container {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  width: 100% !important;
  padding: 0 1.25rem !important;
  box-sizing: border-box !important;
  overflow: visible !important;
  height: 4.5rem !important;
}

@media (min-width: 1280px) {
  .glass-header-container {
    padding: 0 2rem !important;
  }
}

/* القسم الأيمن (الشعار - Logo Container) */
.header-brand-logo {
  flex-shrink: 0 !important;
  min-width: max-content !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.6rem !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  margin: 0 !important;
  padding: 0 !important;
}

.header-brand-logo *,
.hero-name-logo {
  white-space: nowrap !important;
}

.hero-name-logo {
  font-size: 0.9rem !important;
  font-weight: 700 !important;
}

.header-brand-sub {
  font-size: 0.7rem !important;
  line-height: 1.2 !important;
}

html.light .hero-name-logo {
  color: #0f172a !important;
  font-weight: 800 !important;
}

html.light .header-brand-logo .text-slate-400 {
  color: #475569 !important;
}

/* القسم الأوسط (روابط القائمة - Nav Links) */
.header-nav-links {
  flex: 1 !important;
  display: flex !important;
  justify-content: center !important;
  gap: 0.75rem !important; /* Exactly 0.75rem requested */
  align-items: center !important;
  overflow: visible !important;
  padding: 0 0.5rem !important;
}

@media (max-width: 1023px) {
  .header-nav-links {
    display: none !important;
  }
}

/* القسم الأيسر (أزرار الواتساب واللغة - Actions Container) */
.header-actions-group {
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.6rem !important;
  overflow: visible !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Nav Item Single-line enforcement and compact font */
.nav-item {
  font-size: 0.85rem !important; /* 13px / 0.85rem requested */
  white-space: nowrap !important;
  word-break: keep-all !important;
  display: inline-block;
  line-height: 1.2;
  padding: 0.25rem 0.35rem !important;
}

/* WhatsApp CTA Button Styling - Master Compact, Zero Clipping & In-Screen */
.whatsapp-header-btn {
  background-color: #25D366 !important;
  color: #020617 !important;
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-direction: row !important;
  gap: 0.45rem !important;
  white-space: nowrap !important;
  word-break: keep-all !important;
  text-decoration: none !important;
  font-weight: 700 !important;
  font-size: 0.85rem !important; /* Exactly 0.85rem */
  line-height: 1 !important;
  padding: 0.4rem 0.8rem !important; /* Exactly padding: 0.4rem 0.8rem */
  border-radius: 0.65rem !important;
  box-sizing: border-box !important;
  overflow: visible !important;
  margin: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  flex-shrink: 0 !important;
  box-shadow: 0 0 16px rgba(37, 211, 102, 0.35) !important;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  vertical-align: middle !important;
}

.whatsapp-header-btn:hover {
  background-color: #20ba59 !important;
  box-shadow: 0 0 24px rgba(37, 211, 102, 0.55) !important;
  transform: translateY(-1px);
  color: #020617 !important;
}

.whatsapp-header-btn:active {
  transform: translateY(0);
}

.whatsapp-icon-box {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 18px !important; /* Exactly 18px */
  height: 18px !important; /* Exactly 18px */
  overflow: visible !important;
  flex-shrink: 0 !important;
}

.whatsapp-icon-box svg,
.whatsapp-header-btn svg {
  width: 18px !important; /* Exactly 18px */
  height: 18px !important; /* Exactly 18px */
  flex-shrink: 0 !important;
  display: block !important;
  overflow: visible !important;
}

.whatsapp-btn-text {
  display: inline-block !important;
  line-height: 1 !important;
  white-space: nowrap !important;
  vertical-align: middle !important;
}

html.light .whatsapp-header-btn {
  background-color: #25D366 !important;
  color: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
  box-shadow: 0 3px 12px rgba(37, 211, 102, 0.35) !important;
}

html.light .whatsapp-header-btn:hover {
  background-color: #1eb855 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.45) !important;
}

/* Common Header Action Buttons - Standardized 40px Height & Strict Centering */
#theme-toggle-btn,
#lang-toggle-btn {
  height: 2.5rem !important;
  min-height: 2.5rem !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

/* Glow Badges */
.badge-emerald {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
}

html.light .badge-emerald {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.35);
  color: #047857;
}

.badge-cyan {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #38bdf8;
}

html.light .badge-cyan {
  background: rgba(2, 132, 199, 0.1);
  border-color: rgba(2, 132, 199, 0.35);
  color: #0369a1;
}

.badge-indigo {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #818cf8;
}

html.light .badge-indigo {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.35);
  color: #4338ca;
}

.badge-amber {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

html.light .badge-amber {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
  color: #b45309;
}

/* Animations */
@keyframes pulseGlow {
  0%, 100% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

.animate-pulse-glow {
  animation: pulseGlow 4s ease-in-out infinite;
}

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

.cursor-blink {
  display: inline-block;
  width: 8px;
  height: 18px;
  background-color: var(--accent-emerald);
  vertical-align: middle;
  margin-left: 4px;
  animation: terminalBlink 1s infinite;
}

[dir="rtl"] .cursor-blink {
  margin-left: 0;
  margin-right: 4px;
}

/* Terminal Console Styling */
.terminal-window {
  background: #020617;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.8), 0 0 20px rgba(16, 185, 129, 0.05);
  overflow: hidden;
}

.terminal-header {
  background: #0f172a;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.terminal-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-body {
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: #94a3b8;
  max-height: 280px;
  overflow-y: auto;
  line-height: 1.7;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  word-break: break-word;
  animation: fadeIn 0.3s ease;
}

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

/* Filter Tabs */
.filter-tab {
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.6);
  color: #94a3b8;
  white-space: nowrap;
}

.filter-tab:hover {
  background: rgba(30, 41, 59, 0.8);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-tab.active {
  background: #10b981;
  color: #020617;
  border-color: #10b981;
  font-weight: 600;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

/* Project Card & Hover effects */
.project-card {
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.7), 0 0 25px rgba(16, 185, 129, 0.12);
}

.project-img-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #020617;
}

.project-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  transition: transform 0.5s ease;
}

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

/* Lightbox Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #0b1329;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9);
  position: relative;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #10b981;
  color: #020617;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 1100;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

[dir="rtl"] .toast {
  right: auto;
  left: 24px;
}

/* ==========================================================================
   Light Mode Explicit Theme Overrides
   Ensures crisp contrast, clean white/slate backgrounds, and deep readable text
   ========================================================================== */

html.light body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

html.light ::-webkit-scrollbar-track {
  background: #f1f5f9;
}
html.light ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}
html.light ::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Headings and Contrast */
html.light h1,
html.light h2,
html.light h3,
html.light h4,
html.light .text-white {
  color: #0f172a !important;
}

html.light .text-slate-100 {
  color: #0f172a !important;
}

html.light .text-slate-200 {
  color: #1e293b !important;
}

html.light .text-slate-300 {
  color: #334155 !important;
}

html.light .text-slate-400 {
  color: #64748b !important;
}

html.light .bg-\[\#030712\] {
  background-color: var(--bg-primary) !important;
}

/* Dark surface cards in Light Mode */
html.light .bg-slate-900,
html.light .bg-slate-900\/80,
html.light .bg-slate-900\/60,
html.light .bg-slate-950,
html.light .bg-slate-950\/40,
html.light .bg-slate-950\/80,
html.light .bg-slate-950\/95,
html.light .bg-slate-800\/80 {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}

html.light .border-slate-800,
html.light .border-slate-800\/80,
html.light .border-slate-800\/60,
html.light .border-slate-700,
html.light .border-slate-700\/80 {
  border-color: #e2e8f0 !important;
}

/* Header & Navigation */
html.light .glass-header {
  background: rgba(255, 255, 255, 0.95) !important;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
}

html.light .glass-header a.nav-item {
  color: #334155 !important;
}

html.light .glass-header a.nav-item:hover {
  color: #059669 !important;
}

/* Hero Name & Logo High-Contrast Styling */
.hero-name-heading {
  display: inline-block;
  color: #ffffff;
  background: linear-gradient(135deg, #ffffff 30%, #e2e8f0 70%, #10b981 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-name-logo {
  color: #ffffff;
}

/* Light Mode: High-contrast Dark Navy / Royal Black */
html.light .hero-name-heading {
  color: #0f172a !important;
  background: none !important;
  -webkit-background-clip: unset !important;
  background-clip: unset !important;
  -webkit-text-fill-color: #0f172a !important;
  text-shadow: none !important;
}

html.light .hero-name-logo {
  color: #0f172a !important;
}

html.light .hero-name-logo + span {
  background-color: #059669 !important;
}

html.light #mobile-menu {
  background-color: rgba(255, 255, 255, 0.98) !important;
  border-color: #e2e8f0 !important;
}

html.light #theme-toggle-btn,
html.light #lang-toggle-btn {
  background-color: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

html.light #theme-toggle-btn:hover,
html.light #lang-toggle-btn:hover {
  background-color: #e2e8f0 !important;
}

/* Filter Tabs */
html.light .filter-tab {
  background: #ffffff;
  color: #475569;
  border-color: #cbd5e1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

html.light .filter-tab:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

html.light .filter-tab.active {
  background: #059669;
  color: #ffffff !important;
  border-color: #059669;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.3);
}

/* Interactive Terminal Window */
html.light .terminal-window {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 15px 35px -10px rgba(15, 23, 42, 0.12);
}

html.light .terminal-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

html.light .terminal-body {
  background: #ffffff;
  color: #334155;
}

html.light .terminal-body .text-slate-400 {
  color: #475569 !important;
}

html.light .terminal-body .text-slate-600 {
  color: #64748b !important;
}

html.light .terminal-body .text-cyan-400 {
  color: #0284c7 !important;
}

html.light .terminal-body .text-emerald-400 {
  color: #059669 !important;
}

html.light .terminal-body .text-indigo-400 {
  color: #4f46e5 !important;
}

html.light .terminal-body .text-amber-300,
html.light .terminal-body .text-amber-400 {
  color: #d97706 !important;
}

html.light .terminal-window .bg-slate-950\/80 {
  background: #f8fafc !important;
  border-top-color: #e2e8f0 !important;
}

/* Modals */
html.light .modal-overlay {
  background: rgba(15, 23, 42, 0.6);
}

html.light .modal-content {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
}

html.light .modal-content .text-white {
  color: #0f172a !important;
}

html.light .modal-content .bg-slate-800,
html.light .modal-content .bg-slate-900 {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html.light .modal-content .text-slate-200,
html.light .modal-content .text-slate-300 {
  color: #334155 !important;
}

/* Architecture Tabs */
html.light .arch-tab-btn {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #475569;
}

html.light .arch-tab-btn:hover {
  color: #0f172a;
  border-color: #94a3b8;
}

html.light .arch-tab-btn[data-tab].border-emerald-500 {
  background: rgba(16, 185, 129, 0.12) !important;
  color: #047857 !important;
  border-color: #059669 !important;
}

/* Footer in Light Mode */
html.light footer {
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

html.light footer .text-slate-400 {
  color: #64748b !important;
}
