/* ============================================
   pirix - Advanced Client-Side Editor
   Privacy-first • Canva-inspired • Fully Responsive
   ============================================ */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #0f172a;
  --accent: #22d3ee;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #0b1120;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --radius: 12px;
  --shadow: 0 10px 25px -5px rgba(0,0,0,0.4);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========== HEADER ========== */
.header {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0.75rem 1.5rem;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.35rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav a:hover,
.nav a.active {
  color: var(--primary-light);
}

.lang-switcher {
  position: relative;
}

.lang-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.lang-dropdown {
  position: absolute;
  top: 110%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 160px;
  display: none;
  flex-direction: column;
  box-shadow: var(--shadow);
  z-index: 100;
}

.lang-dropdown.show {
  display: flex;
}

.lang-dropdown a {
  padding: 0.6rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.lang-dropdown a:hover {
  background: var(--primary);
  color: white;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
}

/* ========== HERO ========== */
.hero {
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  background: radial-gradient(ellipse at top, rgba(99, 102, 241, 0.15), transparent 60%);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #fff, var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.8rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  padding: 0.4rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 1.5rem;
}

/* ========== AD BANNERS ========== */
.ad-wrapper {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.ad-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.ad-banner {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  position: relative;
  overflow: hidden;
}

.ad-banner.large {
  min-height: 120px;
  width: 100%;
}

.ad-banner.small {
  min-height: 90px;
  max-width: 320px;
  margin: 0 auto;
}

.ad-disclaimer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* ========== FEATURES ========== */
.section {
  padding: 4rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.section-title {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.section-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 3rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  transition: transform 0.2s, border-color 0.2s;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
}

.feature-icon {
  width: 48px;
  height: 48px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 1rem;
  color: var(--primary-light);
}

.feature-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ========== STEPS ========== */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  counter-reset: step;
}

.step {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  position: relative;
  border: 1px solid var(--border);
}

.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.step h3 {
  margin-top: 0.5rem;
  margin-bottom: 0.4rem;
}

.step p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ========== FAQ ========== */
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.faq-question {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 1.1rem 1.25rem;
  text-align: left;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-question:hover {
  color: var(--primary-light);
}

.faq-answer {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  display: none;
  font-size: 0.95rem;
}

.faq-item.open .faq-answer {
  display: block;
}

.faq-item.open .faq-question span {
  transform: rotate(180deg);
}

/* ========== EDITOR LAYOUT ========== */
.editor-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.editor-header {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tool-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.15s;
}

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

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.editor-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 300px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 1rem;
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.canvas-area {
  flex: 1;
  background: #0a0f1a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  position: relative;
  padding: 1.5rem;
}

#canvas-container {
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
  border-radius: 4px;
  background: #1a1a2e;
}

.canvas-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  max-width: 420px;
}

.canvas-placeholder h3 {
  margin-bottom: 0.5rem;
  color: var(--text);
}

.upload-zone {
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
  background: rgba(99, 102, 241, 0.05);
}

.upload-zone:hover,
.upload-zone.dragover {
  background: rgba(99, 102, 241, 0.15);
}

.upload-zone input {
  display: none;
}

.control-group {
  margin-bottom: 0.9rem;
}

.control-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.control-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.control-group input[type="color"],
.control-group select,
.control-group input[type="text"],
.control-group input[type="number"] {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.control-row {
  display: flex;
  gap: 0.5rem;
}

.control-row > * {
  flex: 1;
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  border-radius: 6px;
}

.layers-list {
  list-style: none;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-card);
  border-radius: 6px;
  margin-bottom: 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  border: 1px solid transparent;
}

.layer-item.active {
  border-color: var(--primary);
}

.layer-item .layer-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== LEGAL PAGES ========== */
.legal-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.legal-content h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.legal-content .updated {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.legal-content h2 {
  font-size: 1.3rem;
  margin: 2rem 0 0.75rem;
  color: var(--primary-light);
}

.legal-content p,
.legal-content li {
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.legal-content ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

/* ========== FOOTER ========== */
.footer {
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  padding: 3rem 1.5rem 2rem;
  margin-top: 4rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.footer h4 {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.footer a:hover {
  color: var(--primary-light);
}

.footer-bottom {
  max-width: 1200px;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    bottom: 0;
    z-index: 200;
    transition: left 0.3s;
    width: 280px;
  }

  .sidebar.open {
    left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .nav {
    display: none;
  }

  .nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-sidebar);
    padding: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .editor-main {
    flex-direction: column;
  }

  .canvas-area {
    padding: 0.75rem;
  }
}

@media (max-width: 600px) {
  .hero {
    padding: 2.5rem 1rem;
  }

  .section {
    padding: 2.5rem 1rem;
  }

  .ad-banner.large {
    min-height: 100px;
  }
}

/* RTL support for Arabic */
[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
}

[dir="rtl"] .nav {
  flex-direction: row-reverse;
}

[dir="rtl"] .faq-question {
  text-align: right;
}