/* Base Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* CV global variables */
:root {
  --cv-font-family: 'Cairo', 'Poppins', sans-serif;
  --cv-font-size-base: 12px;
  --cv-accent-color: #a67c00;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #0f172a 0, #020617 45%, #020617 100%);
  color: #e5e7eb;
}

img {
  max-width: 100%;
  display: block;
}

/* Layout */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  gap: 1rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.9);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 1px;
  color: #111827;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 1rem;
  background: radial-gradient(circle at 20% 0, #fbbf24, #f97316);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
}

.brand-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: #9ca3af;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.1fr);
  gap: 1rem;
}

.app-footer {
  margin-top: auto;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: #9ca3af;
  text-align: center;
}

/* Panels */
.panel {
  border-radius: 1rem;
  background: radial-gradient(circle at top left, rgba(15, 118, 110, 0.15), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 1rem 1.1rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.85);
}

.panel-form {
  overflow: hidden;
}

.panel-preview {
  background: radial-gradient(circle at top, rgba(251, 191, 36, 0.04), rgba(15, 23, 42, 0.98));
}

.panel h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-helper {
  margin: 0.4rem 0 0.8rem;
  font-size: 0.78rem;
  color: #9ca3af;
}

/* Language Toggle */
.language-toggle {
  display: inline-flex;
  padding: 0.15rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.language-toggle label {
  font-size: 0.7rem;
  color: #9ca3af;
}

.language-toggle button {
  border: none;
  background: transparent;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #9ca3af;
  cursor: pointer;
}

.language-toggle button.is-active {
  background: linear-gradient(to left, #f97316, #fbbf24);
  color: #0f172a;
  font-weight: 600;
}

/* Template Select */
.template-select {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.template-select label {
  font-size: 0.7rem;
  color: #9ca3af;
}

.template-select select,
.template-select input[type="color"] {
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
}

/* Button */
.btn-primary {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: linear-gradient(to left, #f97316, #fbbf24);
  color: #0f172a;
  box-shadow: 0 10px 25px rgba(251, 191, 36, 0.3);
  white-space: nowrap;
}

.btn-secondary {
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: transparent;
  color: #e5e7eb;
  margin-top: 0.25rem;
}

.btn-secondary:hover {
  background: rgba(148, 163, 184, 0.12);
}

.field-hint {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 0.15rem;
}

.btn-icon {
  font-size: 0.9rem;
}

/* Tabs */
.tabs {
  display: inline-flex;
  gap: 0.3rem;
  margin: 0.6rem 0 0.8rem;
  padding: 0.1rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.45);
}

.tab {
  border: none;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: transparent;
  color: #9ca3af;
  font-size: 0.78rem;
  cursor: pointer;
}

.tab.is-active {
  background: rgba(15, 118, 110, 0.18);
  color: #e5e7eb;
  font-weight: 600;
}

/* Form */
#cvForm {
  margin-top: 0.5rem;
}

.field-group {
  margin-bottom: 0.6rem;
}

.field-group label {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 0.15rem;
  color: #cbd5f5;
}

.field-group input,
.field-group textarea {
  width: 100%;
  border-radius: 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  padding: 0.4rem 0.55rem;
  font-size: 0.8rem;
  resize: vertical;
}

.field-group input::placeholder,
.field-group textarea::placeholder {
  color: #6b7280;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.repeat-group {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  background: #020617;
}

.repeat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.repeat-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}

.repeat-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

/* Preview */
.preview-wrapper {
  margin-top: 0.65rem;
  border-radius: 0.9rem;
  background: #020617;
  padding: 0.45rem;
  border: 1px solid rgba(148, 163, 184, 0.65);
  overflow: auto;
  max-height: calc(100vh - 200px);
}

/* CV Page (A4 ratio-ish) */
.cv-page {
  width: 100%;
  max-width: 760px;
  aspect-ratio: 210 / 297;
  margin: 0 auto;
  background: #ffffff;
  color: #020617;
  border-radius: 0.4rem;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.9);
  font-family: var(--cv-font-family, 'Cairo', 'Poppins', sans-serif);
  font-size: var(--cv-font-size-base, 12px);
}

.cv-photo-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.75rem;
}

.cv-photo {
  width: 90px;
  height: 90px;
  border-radius: 999px;
  object-fit: cover;
  border: 3px solid var(--cv-accent-color, #a67c00);
}

/* مسافات مختلفة للقالبين (اختياري) */
.cv-modern .cv-photo-wrapper {
  margin-bottom: 1rem;
}

.cv-minimal .cv-photo-wrapper {
  margin-bottom: 0.6rem;
}

/* Modern template */
.cv-modern {
  display: grid;
  grid-template-columns: 1.1fr 2fr;
  min-height: 100%;
}

.cv-modern .cv-sidebar {
  background: linear-gradient(to bottom, #0f172a, #111827);
  color: #f9fafb;
  padding: 1.1rem 1rem;
}

.cv-modern .cv-main {
  padding: 1.1rem 1.3rem;
}

.cv-name {
  font-size: 1.6em;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.cv-title {
  font-size: 1em;
  color: #e5e7eb;
  margin-bottom: 0.9rem;
}

.cv-section-title {
  font-weight: 700;
  font-size: 1em;
  letter-spacing: 0;
  margin-bottom: 0.4rem;
}

.cv-section-title span {
  border-bottom: 2px solid var(--cv-accent-color, #a67c00);
  padding-bottom: 0.05rem;
}

.cv-en .cv-section-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}

.cv-sidebar .cv-section + .cv-section {
  margin-top: 0.9rem;
}

.cv-main .cv-section + .cv-section {
  margin-top: 0.9rem;
}

.cv-contact-item {
  font-size: 0.72rem;
  margin-bottom: 0.2rem;
}

.cv-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  background: rgba(15, 23, 42, 0.85);
  color: #e5e7eb;
  margin: 0 0.15rem 0.15rem 0;
}

.cv-body {
  font-size: 0.95em;
  color: #111827;
}

.cv-body p {
  margin: 0 0 0.4rem;
}

.cv-item {
  margin-bottom: 0.4rem;
}

.cv-item-title {
  font-size: 1em;
  font-weight: 600;
}

.cv-item-meta {
  font-size: 0.85em;
  color: #6b7280;
}

.cv-item-desc {
  font-size: 0.9em;
  color: #4b5563;
}


/* RTL / LTR handling */
.preview-wrapper[data-lang="ar"] .cv-page {
  direction: rtl;
}

.preview-wrapper[data-lang="en"] .cv-page {
  direction: ltr;
}

.preview-wrapper.cv-size-small .cv-page {
  transform: scale(0.9);
  transform-origin: top center;
}

.preview-wrapper.cv-size-normal .cv-page {
  transform: scale(1);
  transform-origin: top center;
}

.preview-wrapper.cv-size-large .cv-page {
  transform: scale(1.1);
  transform-origin: top center;
}

/* Responsive */
@media (max-width: 1024px) {
  .app-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-wrapper {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0.75rem;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .tabs {
    width: 100%;
    overflow-x: auto;
  }

  .cv-page {
    aspect-ratio: auto;
  }
}



