:root {
  --background: #050505;
  --foreground: #ffffff;
  --primary-neon: #00f2ff;
  --secondary-neon: #7000ff;
  --accent-neon: #ff00ea;
  --rgb-gradient: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8b00ff);
  --neon-shadow: 0 0 10px var(--primary-neon), 0 0 20px rgba(0, 242, 255, 0.2);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  max-width: 100vw;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--background);
  color: var(--foreground);
  font-family: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
  direction: rtl;
  max-width: 100vw;
  overflow-x: hidden;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(112,0,255,0.1) 0%, transparent 50%),
    radial-gradient(circle at 0% 0%, rgba(0,242,255,0.05) 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(255,0,234,0.05) 0%, transparent 40%);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; display: block; }

/* ADMIN */
.admin-layout input, .admin-layout select, .admin-layout textarea { transition: 0.3s; }
.admin-layout select { cursor: pointer; }
.admin-layout select option { background-color: #111; color: #fff; padding: 10px; }
.admin-layout input:focus, .admin-layout select:focus, .admin-layout textarea:focus {
  border-color: #ffaa00 !important;
  box-shadow: 0 0 15px rgba(255,170,0,0.5) !important;
  outline: none;
}

/* ANIMATIONS */
@keyframes rgb-glow {
  0%   { border-color: var(--primary-neon); box-shadow: 0 0 10px var(--primary-neon); }
  33%  { border-color: var(--accent-neon);  box-shadow: 0 0 10px var(--accent-neon); }
  66%  { border-color: var(--secondary-neon); box-shadow: 0 0 10px var(--secondary-neon); }
  100% { border-color: var(--primary-neon); box-shadow: 0 0 10px var(--primary-neon); }
}
.neon-border { border: 1px solid var(--primary-neon); animation: rgb-glow 5s linear infinite; }

.rgb-text {
  background: var(--rgb-gradient);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: rgb-slide 5s linear infinite;
}
@keyframes rgb-slide { to { background-position: 200% center; } }
@keyframes pulse {
  0%   { transform: scale(1);    opacity: 0.8; }
  50%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1);    opacity: 0.8; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* MARQUEE */
.marquee-container {
  overflow: hidden;
  white-space: nowrap;
  background: rgba(0,0,0,0.95);
  border-top: 1px solid rgba(255,255,255,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 6px 0;
  position: relative;
  z-index: 100;
  box-shadow: 0 0 15px rgba(0,0,0,0.5);
}
.marquee-content { display: flex; width: max-content; will-change: transform; }
.marquee-item { display: inline-block; font-weight: bold; font-size: 1.1rem; letter-spacing: 1px; flex-shrink: 0; padding: 0 30px; }

/* GLASS */
.glass {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0,0,0,0.37);
}

/* HEADER */
header {
  padding: clamp(1.5rem, 5vw, 4rem) 1rem;
  padding-top: calc(clamp(1.5rem, 5vw, 4rem) + var(--safe-top));
  text-align: center;
}
header h1 { font-size: clamp(1.8rem, 7vw, 3.5rem); line-height: 1.2; }

/* BUTTONS */
.glow-btn {
  display: inline-block;
  padding: 12px 24px;
  background: transparent;
  border: 1px solid var(--primary-neon);
  color: var(--primary-neon);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
  font-size: 1rem;
  text-align: center;
  touch-action: manipulation;
  min-height: 44px;
  line-height: 1.2;
  user-select: none;
  -webkit-user-select: none;
}
.glow-btn:hover, .glow-btn:active {
  background: var(--primary-neon);
  color: black;
  box-shadow: 0 0 20px var(--primary-neon);
}

/* GRIDS */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
  padding: 2rem 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem 1rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* CARDS */
.project-card {
  display: flex;
  flex-direction: column;
  min-height: 300px;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fadeIn 0.4s ease both;
}
.category-card {
  min-height: 200px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}
.project-card:hover, .category-card:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: 0 0 30px rgba(0,242,255,0.3);
}
@media (hover: none) {
  .project-card:active, .category-card:active { transform: scale(0.98); }
  .project-card:hover, .category-card:hover { transform: none; box-shadow: none; }
  .category-card:hover .cat-img { transform: none !important; }
}
.category-card:hover .cat-img { transform: scale(1.1); opacity: 0.9; }

.video-container {
  width: 100%;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  height: 220px;
  position: relative;
  background: #111;
}
.video-container video, .video-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-info {
  padding: 1.2rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.project-info h3 { font-size: 1.1rem; margin-bottom: 0.4rem; line-height: 1.3; }
.project-info p  { opacity: 0.7; font-size: 0.875rem; margin-bottom: auto; padding-bottom: 1rem; }

/* CONTACT */
.contact-section {
  padding: 4rem 1rem;
  display: flex;
  justify-content: center;
  background: linear-gradient(180deg, transparent, rgba(112,0,255,0.05));
}
.contact-card { display: flex; flex-direction: column; gap: 0.5rem; }

/* FILTER BTNS */
.filter-btn {
  padding: 10px 20px;
  border: 1px solid var(--primary-neon);
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  border-radius: 20px;
  transition: 0.3s;
  margin: 5px;
  min-height: 44px;
  touch-action: manipulation;
  font-size: 0.9rem;
}
.filter-btn.active, .filter-btn:hover { background: var(--primary-neon); color: #000; box-shadow: 0 0 15px var(--primary-neon); }

/* BACK BTN */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary-neon);
  text-decoration: none;
  font-weight: bold;
  min-height: 44px;
  padding: 8px 0;
}

/* FOOTER */
footer { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* SPLASH */
#splash-screen {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--background);
  display: flex; justify-content: center; align-items: center;
  z-index: 9999; transition: opacity 0.8s ease, visibility 0.8s;
}
#splash-screen.fade-out { opacity: 0; visibility: hidden; }
.splash-logo {
  max-width: min(250px, 70vw);
  max-height: min(250px, 70vh);
  object-fit: contain;
  animation: pulse 2s infinite;
}

/* GALLERY */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}
.media-item {
  border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  transition: all 0.3s ease; position: relative; background: #111;
}
.media-item:hover { border-color: var(--primary-neon); box-shadow: 0 0 20px rgba(0,242,255,0.2); transform: translateY(-5px); }
.media-item img, .media-item video { width: 100%; display: block; object-fit: cover; }
.media-item video { max-height: 400px; }

/* ===== RESPONSIVE ===== */
@media (min-width: 1200px) {
  .portfolio-grid  { grid-template-columns: repeat(4, 1fr); }
  .category-grid   { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 900px) and (max-width: 1199px) {
  .portfolio-grid, .category-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  header { padding: 1.5rem 1rem; }
  header h1 { font-size: clamp(1.5rem, 5vw, 2.2rem); }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem; padding: 0.75rem;
  }
  .category-card { min-height: 140px; }

  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem; padding: 0.75rem;
  }
  .video-container { height: 120px; }
  .project-info { padding: 0.6rem; }
  .project-info h3 { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .project-info p  { font-size: 0.7rem; padding-bottom: 0.4rem; }
  .project-info .glow-btn { padding: 7px 8px; font-size: 0.72rem; min-height: 34px; }
  .project-card { min-height: auto; }

  .marquee-item { font-size: 0.85rem; padding: 0 20px; }
  .glow-btn { padding: 10px 16px; font-size: 0.9rem; }
  .contact-section { padding: 2.5rem 0.75rem; }

  .gallery-grid { grid-template-columns: 1fr; gap: 1rem; padding: 0.5rem; }
  .media-item { border-radius: 8px; }

  /* Admin sidebar on mobile becomes top bar */
  aside.admin-sidebar {
    width: 100% !important;
    border-left: none !important;
    border-bottom: 1px solid rgba(0,242,255,0.2) !important;
    height: auto !important;
    padding: 0.75rem !important;
  }
  aside.admin-sidebar nav {
    display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem;
  }
  aside.admin-sidebar nav a {
    padding: 0.4rem 0.7rem !important;
    font-size: 0.8rem !important;
    display: inline-block !important;
    margin-top: 0 !important;
  }
  main.admin-content { padding: 1rem !important; }
  .admin-form-grid { grid-template-columns: 1fr !important; }

  table thead { display: none; }
  table tr { display: block; margin-bottom: 1.5rem; border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 0.75rem; }
  table td { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0 !important; border-bottom: 1px solid rgba(255,255,255,0.05) !important; font-size: 0.85rem; }
  table td:last-child { border-bottom: none !important; }
  table td::before { content: attr(data-label); font-weight: bold; color: var(--primary-neon); font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .category-grid, .portfolio-grid { gap: 0.5rem; padding: 0.5rem; }
  .video-container { height: 95px; }
  header h1 { font-size: 1.35rem; }
  .header-btns { flex-direction: column; gap: 0.5rem; }
  .header-btns .glow-btn { width: 100%; }
}
