:root {
  /* Premium Professional Palette */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --accent: #10b981;
  --sidebar-bg: #0f172a;
  --sidebar-text: #f8fafc;
  --sidebar-muted: #94a3b8;
  --preview-bg: #f1f5f9;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.1);
  --card-bg: #ffffff;
  
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px; /* 1rem = 16px */
}

body {
  font-family: var(--font-main);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  width: 100%;
}

@media (max-width: 768px) {
  body {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }
  html {
    font-size: 14px; /* Slightly smaller text on mobile */
  }
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 10px;
}

/* --- Sidebar Panel --- */
.editor-panel {
  width: clamp(380px, 30vw, 440px);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #1e293b 100%);
  border-right: 1px solid var(--glass-border);
  height: 100vh;
  padding: 2.5rem 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .editor-panel {
    width: 90vw;
    min-width: 320px;
    height: 100vh;
    border-right: 3px solid rgba(59, 130, 246, 0.5); /* Clear divider */
    border-bottom: none;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
    scroll-snap-align: start;
  }
}

.editor-header {
  position: sticky;
  top: -2.5rem; /* Offsets the parent padding */
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #1e293b 100%);
  padding: 2rem 0 1rem 0;
  margin-top: -2.5rem;
  margin-bottom: 2rem;
  z-index: 50;
  border-bottom: 1px solid var(--glass-border);
}

.editor-header h1 {
  font-size: clamp(1.5rem, 4vw, 1.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.editor-header p {
  color: var(--sidebar-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Form Styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-muted);
}

.form-group input,
.form-group textarea,
.form-group select {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  color: white;
  font-family: inherit;
  font-size: 1rem;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

/* Icon Inputs */
.social-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.icon-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.icon-input-wrapper i {
  position: absolute;
  left: 1.1rem;
  color: var(--sidebar-muted);
  font-size: 1rem;
  pointer-events: none;
}

.icon-input-wrapper input {
  padding-left: 3rem;
  width: 100%;
}

.full-width {
  grid-column: span 2;
}

/* Custom Select Styles */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select-wrapper select {
  width: 100%;
  appearance: none;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1rem 3rem 1rem 1.1rem;
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.custom-select-wrapper select:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.custom-select-wrapper .select-icon {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sidebar-muted);
  pointer-events: none;
  font-size: 0.8rem;
  transition: all 0.3s;
}

.custom-select-wrapper:hover .select-icon {
  color: var(--primary);
}

.custom-select-wrapper select option {
  background-color: var(--sidebar-bg);
  color: white;
  padding: 10px;
}

/* Theme Picker */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.theme-option {
  aspect-ratio: 1;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.theme-option:hover {
  transform: scale(1.1);
  z-index: 2;
  border-color: white;
}

.theme-option.active {
  border-color: white;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
  z-index: 3;
}

/* Actions */
.font-custom-dropdown {
  position: relative;
  width: 100%;
}

.font-selected-trigger {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s;
}

.font-selected-trigger:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
}

.font-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1e293b;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
  z-index: 500;
  max-height: 300px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

#font-dropdown.active .font-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.font-item {
  padding: 0.9rem 1.1rem;
  color: var(--sidebar-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.font-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
  padding-left: 1.5rem;
}

.font-item.active {
  color: var(--primary);
  font-weight: 700;
  background: rgba(79, 70, 229, 0.1);
}

.s-image-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--glass-bg);
  border: 1px dashed var(--glass-border);
  color: white;
  padding: 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.3s;
  width: 100%;
}

.s-image-label:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

.s-thumbnail-preview {
  margin-top: 0.25rem;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  width: 40px;
  height: 40px;
}

.publish-btn {
  width: 100%;
  padding: 1.2rem;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
}

.publish-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.5);
  filter: brightness(1.1);
}

/* --- Preview Area --- */
.preview-viewport {
  flex-grow: 1;
  background-color: var(--preview-bg);
  display: flex;
  flex-direction: column;
  align-items: center; /* Center the frame in the viewport */
  position: relative;
  overflow: hidden; 
  padding: 6rem 1rem 3rem 1rem;
  pointer-events: auto;
}

@media (max-width: 1024px) {
  body {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    height: 100vh;
  }
  .preview-viewport {
    padding: 5rem 0.5rem 2rem 0.5rem;
    height: 100vh;
    min-width: 100vw;
    width: 100vw;
    flex-shrink: 0;
    scroll-snap-align: start;
    overflow: hidden;
  }
  #preview-content {
    height: 100%;
    overflow-y: auto !important;
  }
  .preview-frame {
    height: 100%;
    overflow: hidden;
    padding: 0.5rem;
    border-width: 2px;
    border-radius: 12px;
  }
  .viewport-controls {
    width: 90%;
    flex-wrap: wrap;
    border-radius: 20px;
    position: fixed; /* Keep controls accessible */
    z-index: 100;
  }
}

/* Floating Controls */
.viewport-controls {
  position: absolute;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  padding: 0.5rem;
  border-radius: 40px;
  display: flex;
  gap: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 200;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.control-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 0.6rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
}

.control-btn.active {
  background: var(--primary);
  color: white;
}

.control-btn:hover:not(.active) {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

/* Preview Content Glass Frame */
.preview-frame {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  flex-grow: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: 20px;
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.15);
  overflow: hidden; 
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border: 4px solid white;
  position: relative;
  height: 100%; /* Force height for children to scroll against */
}

#preview-content {
  flex-grow: 1;
  width: 100%;
  max-height: calc(100vh - 9rem);
  overflow-y: auto !important;
  overflow-x: hidden;
  position: relative;
  scroll-behavior: smooth;
  scroll-padding-top: 80px !important;
  -webkit-overflow-scrolling: touch; 
  outline: none;
  container-type: inline-size;
  
  /* Firefox Scrollbar support */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

/* Custom scrollbar for white background preview area */
#preview-content::-webkit-scrollbar {
  width: 8px;
}
#preview-content::-webkit-scrollbar-track {
  background: #f1f5f9;
}
#preview-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
  border: 2px solid #f1f5f9;
}
#preview-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Floating Back to Top Button */
.back-to-top-preview {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 45px;
  height: 45px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.3s;
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
}

.back-to-top-preview.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top-preview:hover {
  transform: scale(1.1);
  background: var(--primary-hover);
}

/* Footer in Sidebar */
.editor-footer {
  margin-top: auto;
  padding-top: 2rem;
  font-size: 0.85rem;
  color: var(--sidebar-muted);
  border-top: 1px solid var(--glass-border);
  line-height: 1.6;
}

/* --- Preview Viewport --- */
.preview-viewport {
  flex-grow: 1;
  background-color: var(--preview-bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.viewport-controls {
  padding: 1.2rem 2rem;
  background: white;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: center;
  gap: 1rem;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.control-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #64748b;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s;
}

.control-btn:hover {
  background: #f1f5f9;
  color: var(--primary);
  border-color: var(--primary);
}

.control-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.preview-frame {
  flex-grow: 1;
  padding: 2.5rem;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background-color: #f1f5f9;
}

#preview-content {
  background: white;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  box-shadow: var(--shadow-premium);
  border-radius: 8px;
  overflow-x: hidden;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0 auto;
  container-type: inline-size;
}

#preview-content::-webkit-scrollbar {
  width: 8px;
}
#preview-content::-webkit-scrollbar-track {
  background: #f1f5f9;
}
#preview-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
#preview-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* --- Animation Utilities --- */
@keyframes fadeInSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInSlideUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- Done-For-You System Styles --- */
.hire-btn {
  width: 100%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 15px rgba(217, 119, 6, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hire-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(217, 119, 6, 0.4);
  filter: brightness(1.1);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1.5rem;
  transition: 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.dfy-modal-content {
  background: #ffffff;
  color: #0f172a;
  width: 100%;
  max-width: 500px;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: modalSlideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dfy-modal-header {
  padding: 2.5rem 2rem 1.5rem 2rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #e2e8f0;
  text-align: center;
}

.dfy-modal-header h2 {
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.dfy-modal-header p {
  font-size: 0.9rem;
  color: #64748b;
}

.dfy-form-body {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.dfy-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.dfy-input-group label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dfy-input-group input,
.dfy-input-group textarea {
  width: 100%;
  padding: 0.9rem 1.1rem;
  border: 2px solid #f1f5f9;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  background: #f8fafc;
  transition: 0.2s;
}

.dfy-input-group textarea {
  min-height: 100px;
  resize: vertical;
}

.dfy-input-group input:focus,
.dfy-input-group textarea:focus {
  outline: none;
  border-color: #f59e0b;
  background: white;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.1);
}

.dfy-pricing-box {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  padding: 1.25rem;
  border-radius: 16px;
  text-align: center;
}

.dfy-price {
  font-weight: 800;
  color: #d97706;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.dfy-trust {
  font-size: 0.75rem;
  color: #92400e;
  font-weight: 600;
}

.dfy-modal-footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.dfy-submit-btn {
  background: #0f172a;
  color: white;
  padding: 1rem;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  font-size: 0.95rem;
}

@media (max-width: 600px) {
  .dfy-modal-header { padding: 1.5rem 1rem 1rem 1rem; }
  .dfy-form-body { padding: 1rem; }
  .dfy-modal-content { max-width: 100%; border-radius: 16px; }
  .preview-viewport { padding-top: 4rem; }
  .viewport-controls { top: 0.5rem; }
  .control-btn { padding: 0.5rem 0.8rem; font-size: 0.75rem; }
}

.dfy-submit-btn:hover {
  background: #1e293b;
  transform: scale(1.02);
}

.dfy-cancel-btn {
  background: transparent;
  color: #64748b;
  padding: 0.5rem;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .dfy-modal-content {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
  }
}
