/* ==========================================================================
   TABLE OF CONTENTS
   ==========================================================================
   1. Variables
   2. Base Styles
   3. Layout (Header & Navigation)
   4. Main Content Area
   5. Modal & Dialog
   6. Form Structure
   7. Standard Inputs
   8. Custom Components (Radio Cards, Color Swatch, Toggles)
   9. Buttons
   10. Utilities
   11. Media Queries
   ========================================================================== */

/* ==========================================================================
   1. Variables
   ========================================================================== */
:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --bg-color: #99baea;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius: 8px;
}

/* ==========================================================================
   2. Base Styles
   ========================================================================== */
body {
  font-family: system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  margin: 0;
  line-height: 1.5;
}

/* ==========================================================================
   3. Layout (Header & Navigation)
   ========================================================================== */
.primary-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.nav-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.primary-header-logo {
  max-height: 48px;
}

.nav-list {
  display: flex;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

.nav-list a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.nav-list a:hover {
  color: var(--primary-color);
}

.btn-settings {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.btn-settings:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

/* ==========================================================================
   4. Main Content Area
   ========================================================================== */
.embedded-form-container {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.iframe-wrapper {
  width: 100%;
  max-width: 900px; /* Slightly wider to accommodate shadows if turned on */
  background: transparent;
  overflow: hidden;
}

/* ==========================================================================
   5. Modal & Dialog
   ========================================================================== */
dialog.modal {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
  width: 90%;
  max-width: 600px;
  background: var(--surface);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-muted);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-main);
}

.modal-footer {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding-block: 1rem;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background-color: var(--surface);
  z-index: 10;
}

/* ==========================================================================
   6. Form Structure
   ========================================================================== */
#style-form {
  padding-inline: 1.5rem;
}

.form-section {
  border: none;
  padding: 0;
  margin: 0 0 1.5rem 0;
}

.form-section legend {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ==========================================================================
   7. Standard Inputs
   ========================================================================== */
label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

input[type="text"],
input[type="number"],
select {
  padding: 0.625rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--text-main);
  background-color: white;
  width: 100%;
  box-sizing: border-box;
}

input:focus,
select:focus {
  outline: 2px solid var(--primary-color);
  border-color: var(--primary-color);
}

/* ==========================================================================
   8. Custom Components
   ========================================================================== */

/* --- Radio Cards --- */
.radio-group-container {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.radio-card {
  position: relative;
  flex: 1;
  cursor: pointer;
}

.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.radio-card .radio-content {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.radio-card:hover .radio-content {
  border-color: var(--primary-color);
}

.radio-card input[type="radio"]:checked + .radio-content {
  background-color: var(--primary-color);
  color: var(--surface);
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.radio-card input[type="radio"]:focus + .radio-content {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 30%, transparent);
}

/* --- Color Input Wrapper --- */
.color-input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-swatch {
  height: 40px;
  width: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: none;
}

/* --- Toggle Switch --- */
.toggle-group {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-muted);
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* ==========================================================================
   9. Buttons
   ========================================================================== */
.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background-color: white;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary:hover {
  background-color: var(--surface-muted);
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
}

.icon-btn:hover {
  background-color: #e2e8f0;
  color: var(--text-main);
}

/* ==========================================================================
   10. Utilities
   ========================================================================== */
.help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  white-space: nowrap;
}

/* ==========================================================================
   11. Media Queries
   ========================================================================== */
.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
}

@media (max-width: 62.5rem) {
  .mobile-nav-toggle {
    display: block;
  }

  .primary-navigation {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }

  .primary-navigation[data-visible="true"] {
    display: block;
  }

  .nav-list {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}