:root {
  --ink: #10231f;
  --muted: #66756f;
  --brand: #0f766e;
  --brand-dark: #0b534d;
  --gold: #c58b2b;
  --soft: #f5f8f6;
  --line: #dfe8e3;
  --white: #ffffff;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(16, 35, 31, .10);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  direction: rtl;
  font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(197, 139, 43, .12), transparent 32%),
    radial-gradient(circle at 85% 10%, rgba(15, 118, 110, .12), transparent 30%),
    var(--soft);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(223, 232, 227, .85);
}

.nav {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  color: var(--brand-dark);
  letter-spacing: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 12px 28px rgba(15, 118, 110, .25);
  overflow: hidden;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-title {
  display: grid;
  line-height: 1.1;
}

.brand-title small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #43514c;
  font-weight: 600;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  text-align: center;
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--brand-dark);
  background: #e9f4f1;
}

.hero {
  padding: 58px 0 30px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 42px;
  align-items: center;
}

.hero h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 78px);
  line-height: 1.05;
  letter-spacing: 0;
  color: var(--brand-dark);
}

.hero p {
  margin: 22px 0 0;
  color: #43514c;
  font-size: 20px;
  line-height: 1.8;
  max-width: 660px;
}

.hero-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.btn {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: var(--white); box-shadow: 0 14px 24px rgba(15, 118, 110, .2); }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-soft { background: #eaf4f1; color: var(--brand-dark); }
.btn-gold { background: #fff2da; color: #7a4d09; }
.btn-danger { background: #fee4e2; color: var(--danger); }
.btn-block { width: 100%; }

.hero-preview {
  min-height: 460px;
  position: relative;
  display: grid;
  place-items: center;
}

.phone-stack {
  width: min(330px, 78vw);
  aspect-ratio: 9 / 16;
  border-radius: 36px;
  padding: 14px;
  background: linear-gradient(160deg, #ffffff, #e8f2ef);
  box-shadow: var(--shadow);
  transform: rotate(-3deg);
}

.phone-card {
  height: 100%;
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(160deg, #0f766e, #17443e 55%, #c58b2b);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px;
  position: relative;
}

.phone-card::before {
  content: "";
  position: absolute;
  inset: 36px 34px auto;
  height: 36%;
  border-radius: 999px;
  border: 2px solid rgba(197, 139, 43, .34);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 18px 42px rgba(197, 139, 43, .10);
}

.phone-card strong {
  font-size: 34px;
  line-height: 1.25;
  position: relative;
}

.phone-card span {
  margin-top: 14px;
  color: rgba(255,255,255,.82);
  position: relative;
}

.search-wrap {
  margin: 28px auto 8px;
  width: min(720px, 100%);
  position: relative;
}

.search-wrap input {
  width: 100%;
  height: 62px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 54px 0 22px;
  background: var(--white);
  color: var(--ink);
  outline: none;
  box-shadow: 0 10px 28px rgba(16, 35, 31, .05);
}

.search-wrap svg {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.category-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 18px 0 12px;
  scrollbar-width: thin;
}

.chip {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--white);
  color: #43514c;
  padding: 11px 16px;
  border-radius: 999px;
  font-weight: 800;
}

.chip.active {
  color: var(--white);
  background: var(--brand);
  border-color: var(--brand);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin: 38px 0 20px;
}

.section-head h2 {
  margin: 0;
  font-size: 30px;
  color: var(--ink);
}

.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.category-sections {
  display: grid;
  gap: 28px;
  padding-bottom: 72px;
}

.template-category-section {
  --category-color: var(--brand);
  position: relative;
  padding: 24px;
  border: 1px solid color-mix(in srgb, var(--category-color) 18%, #e5ece8);
  border-radius: 28px;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--category-color) 15%, transparent), transparent 34%),
    linear-gradient(135deg, color-mix(in srgb, var(--category-color) 8%, #ffffff), #ffffff 58%);
  box-shadow: 0 18px 42px rgba(16, 35, 31, .055);
  overflow: hidden;
}

.template-category-section::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--category-color);
}

.template-category-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  text-align: center;
}

.template-category-head h3 {
  margin: 4px 0 0;
  font-size: 28px;
  color: var(--category-color);
}

.category-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--category-color) 11%, #ffffff);
  color: var(--category-color);
  font-size: 13px;
  font-weight: 900;
}

.category-count {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-radius: 999px;
  background: #fff;
  color: var(--category-color);
  border: 1px solid color-mix(in srgb, var(--category-color) 22%, #e5ece8);
  font-weight: 900;
}

#faq .section-head {
  justify-content: center;
  text-align: center;
}

#faq .section-head > div {
  max-width: 680px;
  margin-inline: auto;
}

.template-card {
  background: var(--white);
  border: 1px solid rgba(223, 232, 227, .9);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(16, 35, 31, .06);
  transition: transform .18s ease, box-shadow .18s ease;
}

.template-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.template-thumb {
  background: #e7eee9;
  aspect-ratio: 9 / 16;
  overflow: hidden;
}

.template-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-meta {
  padding: 14px;
}

.template-meta h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.template-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.page {
  padding: 34px 0 70px;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(300px, 430px) 1fr;
  gap: 24px;
  align-items: start;
}

.panel {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 32px rgba(16, 35, 31, .06);
}

.panel-pad { padding: 22px; }

.form-grid {
  display: grid;
  gap: 14px;
}

.field label {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
  color: #25342f;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 46px;
  padding: 10px 13px;
  outline: none;
  background: #fff;
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.canvas-shell {
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 620px;
}

.canvas-frame {
  width: min(430px, 100%);
  aspect-ratio: 9 / 16;
  border-radius: 24px;
  overflow: hidden;
  background: #eef4f1;
  box-shadow: var(--shadow);
}

.canvas-frame[data-aspect="square"] {
  width: min(520px, 100%);
}

.canvas-frame[data-aspect="horizontal"] {
  width: min(760px, 100%);
}

.canvas-frame canvas {
  width: 100% !important;
  height: 100% !important;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

.admin-sidebar {
  background: var(--brand-dark);
  color: var(--white);
  padding: 24px;
}

.admin-sidebar a {
  display: block;
  padding: 13px 14px;
  border-radius: 14px;
  color: rgba(255,255,255,.85);
  margin-top: 8px;
}

.admin-sidebar a.active,
.admin-sidebar a:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.admin-main {
  padding: 28px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0 24px;
}

.stat {
  padding: 18px;
  border-radius: 20px;
  color: white;
  background: var(--brand);
  box-shadow: 0 12px 28px rgba(16, 35, 31, .1);
}

.stat:nth-child(2) { background: #8a5a12; }
.stat:nth-child(3) { background: #3f6f68; }
.stat:nth-child(4) { background: #374151; }
.stat strong { display: block; font-size: 28px; margin-top: 10px; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(16, 35, 31, .05);
}

.table th,
.table td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

.table th { background: #eef6f3; color: var(--brand-dark); }
.table tr:nth-child(even) td { background: #fbfdfc; }
.mini-img { width: 64px; height: 96px; border-radius: 12px; object-fit: cover; background: #eef4f1; }

.bulk-template-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.bulk-template-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(16, 35, 31, .055);
  overflow: hidden;
}

.bulk-template-card img {
  width: 100%;
  height: 230px;
  object-fit: contain;
  background: #f4f7f5;
}

.bulk-template-card div {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.bulk-template-card strong {
  color: var(--ink);
}

.bulk-template-card small {
  color: var(--muted);
}

.alert {
  padding: 14px 16px;
  border-radius: 16px;
  margin: 14px 0;
  background: #ecfdf3;
  color: #05603a;
  border: 1px solid #abefc6;
}

.alert.error {
  background: #fff1f3;
  color: #b42318;
  border-color: #fecdd6;
}

.empty {
  padding: 46px 18px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.faq-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding-bottom: 72px;
}

.faq-item {
  background: #fff;
  border: 1px solid rgba(223, 232, 227, .9);
  border-radius: 20px;
  box-shadow: 0 12px 26px rgba(16, 35, 31, .055);
  overflow: hidden;
  position: relative;
}

.faq-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--faq-accent, var(--brand));
}

.faq-tone-1 { --faq-accent: #0f766e; --faq-bg: #ecfdf8; }
.faq-tone-2 { --faq-accent: #c58b2b; --faq-bg: #fffbeb; }
.faq-tone-3 { --faq-accent: #7c6f57; --faq-bg: #f7f3ea; }
.faq-tone-4 { --faq-accent: #5f8f83; --faq-bg: #f0f7f5; }

.faq-item[open] {
  background: linear-gradient(135deg, var(--faq-bg, #fff), #fff 62%);
}

.faq-item summary {
  cursor: pointer;
  padding: 18px 22px 18px 28px;
  font-weight: 900;
  color: #173f39;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: right;
  direction: rtl;
}

.faq-item summary span {
  flex: 1;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  flex: 0 0 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--faq-accent, var(--brand));
  font-weight: 900;
}

.faq-item[open] summary::after {
  content: "-";
}

.faq-item p {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0 22px 22px 34px;
  color: #43514c;
  font-size: 18px;
  line-height: 2;
  text-align: right !important;
  text-align-last: right;
  direction: rtl;
  max-width: none;
  white-space: normal;
  word-spacing: normal;
  letter-spacing: 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px 0;
  background: #fff;
  color: var(--muted);
}

.footer-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 960px) {
  .hero-grid,
  .editor-layout,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .templates-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .template-category-section {
    padding: 18px;
  }

  .faq-list {
    grid-template-columns: 1fr;
  }

  .bulk-template-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-preview { min-height: auto; }
  .nav { align-items: flex-start; flex-direction: column; padding: 14px 0; }
  .nav-links {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    gap: 8px;
    scroll-snap-type: x proximity;
  }
  .nav-links a {
    flex: 0 0 auto;
    min-width: 104px;
    min-height: 48px;
    padding: 9px 14px;
    scroll-snap-align: start;
  }
  .editor-layout .canvas-shell {
    order: -1;
  }
  .editor-layout .panel-pad {
    order: 1;
  }
  .canvas-shell {
    min-height: auto;
  }
  .admin-sidebar { position: static; }
}

@media (max-width: 560px) {
  .templates-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .container { width: min(100% - 20px, 1180px); }
  .hero { padding-top: 34px; }
  .hero h1 { font-size: 38px; }
  .hero p { font-size: 17px; }
  .template-meta h3 { font-size: 14px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .category-sections {
    gap: 18px;
  }
  .template-category-head {
    align-items: center;
    flex-direction: column;
  }
  .template-category-head h3 {
    font-size: 24px;
  }
  .category-count {
    width: fit-content;
    margin-inline: auto;
  }
  .bulk-template-grid {
    grid-template-columns: 1fr;
  }
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }
  .section-head .btn {
    width: 100%;
  }
  .faq-item summary {
    padding: 18px 18px 14px;
    align-items: flex-start;
  }
  .faq-item summary span {
    font-size: 22px;
    line-height: 1.55;
  }
  .faq-item summary::after {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
  }
  .faq-item p {
    padding: 0 18px 22px;
    font-size: 18px;
    line-height: 2;
  }
  .actions .btn {
    min-height: 52px;
  }
  .canvas-shell {
    padding: 14px;
  }
  .canvas-frame[data-aspect="horizontal"] {
    width: 100%;
  }
}
