@import url("https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Cairo:wght@400;600;700;800&family=IBM+Plex+Sans+Arabic:wght@400;600;700&family=Noto+Kufi+Arabic:wght@400;600;700&family=Tajawal:wght@400;500;700;800&display=swap");

:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --text: #151515;
  --muted: #69645d;
  --border: #ddd7cd;
  --accent: #0d5c63;
  --accent-strong: #0a474d;
  --danger: #9f2d20;
  --shadow: 0 18px 45px rgba(34, 30, 24, 0.08);
  --header-bg: #f6f3ee;
  --font-family: Tahoma, Arial, sans-serif;
  --font-size-base: 16px;
}

@import url("https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Cairo:wght@400;600;700;800&family=IBM+Plex+Sans+Arabic:wght@400;600;700&family=Noto+Kufi+Arabic:wght@400;600;700&family=Tajawal:wght@400;500;700;800&display=swap");

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(246, 243, 238, 0.9), rgba(246, 243, 238, 0.9)),
    var(--page-bg-image),
    var(--bg);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #121313;
  --surface: #1c1e1f;
  --surface-soft: #242728;
  --text: #f2f2ee;
  --muted: #c4c0b8;
  --border: #3b3f40;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(249, 250, 247, 0.88)),
    var(--header-bg);
  border: 1px solid rgba(221, 215, 205, 0.9);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.site-brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.site-logo {
  width: 82px;
  min-width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 900;
  text-align: center;
  box-shadow: 0 12px 30px rgba(34, 30, 24, 0.08);
}

.site-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.site-nav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(34, 30, 24, 0.05);
}

.site-nav a span,
.nav-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  margin-inline-end: 7px;
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(13, 92, 99, 0.14), rgba(214, 158, 46, 0.2));
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.key-mark {
  background: linear-gradient(135deg, #f8df8f, #c79724);
  color: #342300;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.site-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.gear-icon {
  font-size: 18px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.2;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

.subtitle,
.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel,
.output-panel {
  padding: 22px;
}

.section-head {
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--text);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(13, 92, 99, 0.13);
}

.voice-field {
  gap: 8px;
}

.voice-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.voice-picker select {
  min-width: 0;
}

.voice-picker button {
  white-space: nowrap;
  min-height: 48px;
}

.voice-field small {
  color: var(--muted);
  font-weight: 700;
}

.voice-note-button {
  background: #fff7e6;
  color: #795200;
}

.voice-note-display {
  display: block;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fffdf7;
  color: var(--muted);
  line-height: 1.7;
}

.voice-note-display.has-note {
  border-color: #d69e2e;
  background: #fff8df;
  color: #6b4a00;
}

.settings-hub-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.settings-card-button {
  min-height: 130px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 16px;
  text-align: right;
  display: grid;
  align-content: center;
  gap: 8px;
  cursor: pointer;
}

.settings-card-button strong {
  color: var(--accent);
  font-size: 20px;
}

.settings-card-button span {
  color: var(--muted);
  line-height: 1.7;
}

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

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

.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.length-control span::before,
.diacritics-control span::before {
  content: "≡";
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: 7px;
  border-radius: 6px;
  background: #eef3ef;
  color: var(--accent);
  font-weight: 900;
}

.diacritics-control span::before {
  content: "ض";
}

.highlight-field textarea {
  border-color: rgba(159, 45, 32, 0.45);
  background: #fff8f5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.ghost-button {
  background: #e7ebe3;
  color: #152f32;
}

.api-button,
.tts-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.api-button {
  background: #111827;
  color: #fff;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.18);
}

.api-button:hover {
  background: #243142;
}

.tts-button {
  background: #8b2f18;
  color: #fff;
  box-shadow: 0 10px 24px rgba(139, 47, 24, 0.18);
}

.tts-button:hover {
  background: #702513;
}

.key-icon,
.sound-icon {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  font-size: 12px;
  letter-spacing: 0;
}

.danger-button {
  background: #f3dfda;
  color: var(--danger);
}

.icon-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  min-width: 108px;
}

.icon-action svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-action svg path:first-child:last-child {
  fill: currentColor;
  stroke: none;
}

.tts-dialog .icon-action,
.audio-panel .icon-action {
  border: 1px solid rgba(13, 92, 99, 0.12);
}

.audio-panel .actions,
.tts-dialog .actions {
  align-items: center;
}

.output-panel {
  position: sticky;
  top: 18px;
}

.output-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.metrics span {
  display: inline-flex;
  align-items: center;
  height: 32px;
  border-radius: 8px;
  background: #edf3f1;
  color: var(--accent-strong);
  padding: 0 10px;
  font-weight: 800;
  white-space: nowrap;
}

.script-output {
  min-height: 660px;
  background: #fffdf9;
  line-height: 1.9;
  font-size: 17px;
}

.output-actions {
  justify-content: flex-start;
}

.script-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.script-toolbar button {
  min-height: 38px;
  background: #e7ebe3;
  color: #153235;
  padding: 8px 12px;
}

.script-toolbar button.is-active {
  background: var(--accent);
  color: #fff;
}

.history-panel {
  margin-top: 18px;
  padding: 18px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fffdf9;
  padding: 12px;
}

.history-item strong {
  display: block;
  margin-bottom: 3px;
}

.history-item span {
  color: var(--muted);
  font-size: 14px;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.audio-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfbf7;
  padding: 14px;
}

.audio-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.audio-panel h2 {
  margin-bottom: 3px;
  font-size: 20px;
}

.audio-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.ai-disclosure {
  margin-top: 6px;
  color: #7a4a18;
  font-size: 13px;
  font-weight: 700;
}

.audio-player {
  width: 100%;
  margin-bottom: 10px;
}

.tts-button.compact {
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
}

.settings-dialog {
  width: min(860px, calc(100% - 28px));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
}

#visitorEmailDialog,
#adminLoginDialog {
  width: min(720px, calc(100% - 28px));
  border: 1px solid #3b3b3b;
  border-radius: 8px;
  color: #f5f5f5;
  background:
    radial-gradient(circle at 18% 0%, rgba(215, 174, 79, 0.14), transparent 30%),
    #1f1f1f;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.38);
}

#visitorEmailDialog form,
#adminLoginDialog form {
  padding: clamp(26px, 5vw, 48px);
}

#visitorEmailDialog .section-head,
#adminLoginDialog .section-head {
  margin-bottom: 22px;
}

#visitorEmailDialog h2,
#adminLoginDialog h2 {
  color: #f5f5f5;
  font-size: clamp(28px, 5vw, 44px);
}

#visitorEmailDialog p,
#adminLoginDialog p,
#visitorEmailDialog label span,
#adminLoginDialog label span {
  color: #b8b8b8;
}

#visitorEmailDialog input,
#adminLoginDialog input {
  min-height: 56px;
  border-color: #3b3b3b;
  border-radius: 8px;
  color: #f5f5f5;
  background: #191919;
}

#visitorEmailDialog input:focus,
#adminLoginDialog input:focus {
  border-color: #a8ff96;
  box-shadow: 0 0 0 3px rgba(168, 255, 150, 0.15);
}

#visitorEmailDialog .primary-button,
#adminLoginDialog .primary-button {
  background: #a8ff96;
  color: #111;
}

#visitorEmailDialog .secondary-button,
#adminLoginDialog .secondary-button {
  border: 1px solid #3b3b3b;
  color: #f5f5f5;
  background: #292929;
}

#visitorEmailDialog .api-status,
#adminLoginDialog .api-status {
  border-color: #3b3b3b;
  background: rgba(255, 255, 255, 0.08);
  color: #a8ff96;
}

.settings-dialog form {
  padding: 22px;
}

.settings-dialog::backdrop {
  background: rgba(20, 18, 15, 0.45);
}

.appearance-dialog {
  width: min(920px, calc(100% - 28px));
}

body.icon-solid .icon-action svg {
  fill: currentColor;
  stroke-width: 1.5;
}

.api-status {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f4f7f2;
  color: var(--accent-strong);
  padding: 12px 13px;
  margin-bottom: 16px;
  font-weight: 800;
}

.admin-button {
  border-color: rgba(13, 92, 99, 0.28);
}

.admin-only {
  display: none !important;
}

body.admin-authenticated .admin-only {
  display: inline-flex !important;
}

body.execution-locked .primary-button,
body.execution-locked #generateButton,
body.execution-locked #mainGenerateVoiceButton {
  opacity: 0.62;
}

body.execution-locked .output-panel::before {
  content: "وضع مشاهدة فقط - سجّل دخول الأدمن لتفعيل التوليد والصوت";
  display: block;
  margin-bottom: 12px;
  border: 1px solid rgba(159, 45, 32, 0.25);
  border-radius: 8px;
  background: rgba(159, 45, 32, 0.08);
  color: var(--danger);
  padding: 10px 12px;
  font-weight: 900;
}

.tts-dialog {
  width: min(1080px, calc(100% - 28px));
}

.tts-dialog audio {
  width: 100%;
  margin: 6px 0 14px;
}

.tts-dialog input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.voice-clone-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
  margin: 12px 0;
}

.compact-head {
  margin-bottom: 10px;
}

.compact-head h3,
.compact-head p {
  margin: 0;
}

.consent-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 900;
}

.clone-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.voice-test-sample {
  display: block;
  margin-top: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.7;
}

@media (max-width: 1050px) {
  .voice-picker {
    grid-template-columns: 1fr;
  }

  .workspace,
  .two,
  .three,
  .four,
  .five,
  .settings-hub-grid {
    grid-template-columns: 1fr;
  }

  .output-panel {
    position: static;
  }

  .script-output {
    min-height: 460px;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 18px;
  }

  .topbar,
  .output-head,
  .audio-panel-head,
  .history-item {
    display: grid;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .site-brand-block {
    align-items: flex-start;
  }

  .site-nav {
    justify-content: stretch;
  }

  .site-nav a {
    flex: 1 1 120px;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    width: 100%;
    justify-content: center;
  }

  h1 {
    font-size: 30px;
  }

  .form-panel,
  .output-panel {
    padding: 16px;
  }
}
.pricing-nav-link {
  border-color: rgba(142, 111, 42, 0.5) !important;
  background: rgba(142, 111, 42, 0.14) !important;
}
