/* ============================================
   ELEMENTHA - Base Styles & Reset
   ============================================ */

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

html {
  direction: rtl;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.7;
  color: var(--clr-text);
  background-color: var(--clr-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-slow), color var(--transition-slow);
  overflow-x: hidden;
}

/* Focus Styles */
:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Selection */
::selection {
  background: rgba(109, 40, 217, 0.2);
  color: var(--clr-primary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--clr-bg-3); }
::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--clr-text-3); }

/* Typography Reset */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--clr-text);
}

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); }

p { color: var(--clr-text-2); }
a { color: var(--clr-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--clr-secondary); }

img, svg, video { display: block; max-width: 100%; }
button { font-family: var(--font-family); cursor: pointer; }
input, textarea, select { font-family: var(--font-family); }
ul, ol { list-style: none; }

/* Layout Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.container--narrow { max-width: 860px; }
.container--wide   { max-width: 1440px; }

/* Grid System */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: var(--space-6); }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: var(--space-6); }
.grid-4 { grid-template-columns: repeat(4, 1fr); gap: var(--space-6); }

/* Flex Utils */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }

/* Spacing Utils */
.mt-auto { margin-top: auto; }
.section-pad { padding-block: var(--space-24); }
.section-pad-sm { padding-block: var(--space-16); }

/* Text Utils */
.text-center { text-align: center; }
.text-primary { color: var(--clr-primary); }
.text-accent  { color: var(--clr-accent); }
.text-muted   { color: var(--clr-text-2); }
.text-sm      { font-size: var(--font-size-sm); }
.text-xs      { font-size: var(--font-size-xs); }
.font-bold    { font-weight: 700; }
.font-medium  { font-weight: 500; }

/* Card Base */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(109, 40, 217, 0.2);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge--free    { background: rgba(16,185,129,0.12); color: var(--clr-success); }
.badge--pro     { background: var(--gradient-primary); color: white; }
.badge--new     { background: rgba(6,182,212,0.12); color: var(--clr-accent); }
.badge--popular { background: rgba(245,158,11,0.12); color: var(--clr-warning); }

/* Section Headers */
.section-header {
  text-align: center;
  max-width: 640px;
  margin-inline: auto;
  margin-bottom: var(--space-12);
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--clr-primary);
  background: var(--clr-primary-light);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  margin-bottom: var(--space-4);
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: var(--font-size-lg);
  color: var(--clr-text-2);
  line-height: 1.7;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-shine);
  opacity: 0;
  transition: opacity var(--transition-base);
  background-size: 200% 100%;
}

.btn:hover::after { opacity: 1; }

.btn--primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-primary);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(109,40,217,0.35); color: white; }

.btn--secondary {
  background: var(--clr-surface);
  color: var(--clr-primary);
  border-color: var(--clr-border);
}
.btn--secondary:hover { border-color: var(--clr-primary); background: var(--clr-primary-light); }

.btn--accent {
  background: var(--clr-accent);
  color: white;
  box-shadow: var(--shadow-accent);
}
.btn--accent:hover { transform: translateY(-2px); background: var(--clr-accent-hover); color: white; }

.btn--ghost {
  background: transparent;
  color: var(--clr-text-2);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--clr-bg-3); color: var(--clr-text); }

.btn--lg { padding: var(--space-4) var(--space-8); font-size: var(--font-size-base); border-radius: var(--radius-xl); }
.btn--sm { padding: var(--space-2) var(--space-4); font-size: var(--font-size-xs); border-radius: var(--radius-md); }
.btn--icon { width: 40px; height: 40px; padding: 0; border-radius: var(--radius-md); }

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Progress Bar */
#scroll-progress {
  position: fixed;
  top: 0;
  right: 0;
  width: 0%;
  height: 3px;
  background: var(--gradient-primary);
  z-index: calc(var(--z-header) + 10);
  transition: width 0.1s linear;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  left: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--clr-text);
  pointer-events: all;
  animation: toastIn 0.4s var(--transition-bounce) forwards;
  min-width: 280px;
  max-width: 380px;
}

.toast.hiding { animation: toastOut 0.3s ease forwards; }
.toast--success { border-right: 3px solid var(--clr-success); }
.toast--error   { border-right: 3px solid var(--clr-danger); }
.toast--info    { border-right: 3px solid var(--clr-accent); }

.toast__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.toast--success .toast__icon { background: rgba(16,185,129,0.12); color: var(--clr-success); }
.toast--error   .toast__icon { background: rgba(239,68,68,0.12);   color: var(--clr-danger); }
.toast--info    .toast__icon { background: rgba(6,182,212,0.12);   color: var(--clr-accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-20px); }
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--clr-bg-3) 25%, var(--clr-border-light) 50%, var(--clr-bg-3) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Scroll To Top */
#scroll-top {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-6);
  width: 44px;
  height: 44px;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-primary);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(16px);
  transition: all var(--transition-base);
  pointer-events: none;
  font-size: 18px;
}

#scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

#scroll-top:hover { transform: translateY(-3px); }

/* Lightbox */
#elementha-lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

#elementha-lightbox.active {
  opacity: 1;
  pointer-events: all;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lightbox__content {
  position: relative;
  width: 100%;
  max-width: 1100px;
  height: 85vh;
  background: var(--clr-surface);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
}

.lightbox__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.lightbox__title {
  font-size: var(--font-size-base);
  font-weight: 600;
}

.lightbox__close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-bg-3);
  border: none;
  border-radius: var(--radius-md);
  color: var(--clr-text-2);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.lightbox__close:hover { background: var(--clr-danger); color: white; }

.lightbox__iframe {
  flex: 1;
  width: 100%;
  border: none;
}

/* Overlay Loader */
.elementha-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-16);
  color: var(--clr-text-2);
  font-size: var(--font-size-sm);
  gap: var(--space-3);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Media Queries - Mobile First */
@media (max-width: 1024px) {
  :root { --container-pad: var(--space-5); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root {
    --header-height: 60px;
    --container-pad: var(--space-4);
  }
  h1 { font-size: var(--font-size-3xl); }
  h2 { font-size: var(--font-size-2xl); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .section-pad { padding-block: var(--space-16); }
  .section-title { font-size: var(--font-size-2xl); }
  #toast-container { left: var(--space-4); right: var(--space-4); }
  .toast { min-width: unset; max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
