:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --bg-gradient: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
  --surface: rgba(255, 255, 255, 0.6);
  --surface-blur: blur(20px);
  --border: rgba(255, 255, 255, 0.8);
  --text: #1f2937;
  --text-light: #4b5563;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius: 16px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
}

/* Animated Background Shapes */
.bg-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  animation: float 10s infinite ease-in-out alternate;
}

.shape-1 {
  width: 400px;
  height: 400px;
  background: rgba(99, 102, 241, 0.3);
  top: -100px;
  left: -100px;
}

.shape-2 {
  width: 500px;
  height: 500px;
  background: rgba(236, 72, 153, 0.2);
  bottom: -200px;
  right: -100px;
  animation-delay: -5s;
}

.shape-3 {
  width: 300px;
  height: 300px;
  background: rgba(59, 130, 246, 0.2);
  top: 40%;
  left: 30%;
  animation-delay: -2s;
}

@keyframes float {
  0% {
    transform: translateY(0) scale(1);
  }

  100% {
    transform: translateY(30px) scale(1.1);
  }
}

/* Layout */
.main-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.header {
  text-align: center;
  margin-bottom: 10px;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  background: linear-gradient(to right, #2563eb, #db2777);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header p {
  color: var(--text-light);
  font-size: 1.1rem;
}

.workspace {
  position: relative;
  min-height: 500px;
}

.panel {
  background: var(--surface);
  backdrop-filter: var(--surface-blur);
  -webkit-backdrop-filter: var(--surface-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}

.panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  position: relative;
}

/* Dropzone */
.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  cursor: pointer;
  border: 2px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius);
  transition: all 0.3s ease;
  min-height: 400px;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.drop-icon {
  width: 80px;
  height: 80px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  transition: transform 0.3s;
}

.drop-zone:hover .drop-icon {
  transform: scale(1.1);
}

.drop-zone h3 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.drop-zone p {
  color: var(--text-light);
}

/* Editor Section */
.editor-panel {
  display: flex;
  min-height: 600px;
}

.controls-sidebar {
  width: 320px;
  padding: 30px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.8);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 500;
}

.file-info span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-icon {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(239, 68, 68, 0.1);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-group label {
  font-weight: 600;
  font-size: 0.95rem;
}

.control-group small {
  color: var(--text-light);
  line-height: 1.4;
}

.layout-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-layout {
  flex: 1 1 calc(33.33% - 8px);
  min-width: 60px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-layout:hover {
  background: white;
}

.btn-layout.active {
  border-color: var(--primary);
  background: white;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.btn-layout.active .layout-icon {
  border-color: var(--primary);
}

.layout-icon {
  width: 32px;
  height: 44px;
  border: 2px solid #ddd;
  border-radius: 4px;
  display: grid;
  gap: 2px;
  padding: 2px;
  transition: border-color 0.2s;
}

.layout-icon div {
  background: #eee;
  border-radius: 1px;
  transition: background 0.2s;
}

.btn-layout.active .layout-icon div {
  background: rgba(99, 102, 241, 0.4);
}

/* 2 Pages Vertical */
.grid-2-v {
  grid-template-rows: 1fr 1fr;
}

/* 2 Pages Horizontal */
.grid-2-h {
  grid-template-columns: 1fr 1fr;
}

/* 4 Pages Grid (Square) */
.grid-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* 4 Pages Vertical */
.grid-4-v {
  grid-template-rows: 1fr 1fr 1fr 1fr;
}

/* 4 Pages Horizontal */
.grid-4-h {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--primary);
}

input:checked+.slider:before {
  transform: translateX(22px);
}

.btn-primary {
  margin-top: auto;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
  transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  box-shadow: none;
}

.status-message {
  font-size: 0.9rem;
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  padding: 12px;
  border-radius: 8px;
  display: none;
  align-items: center;
  gap: 8px;
}

.status-message.visible {
  display: flex;
}

/* Preview Area */
.preview-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: rgba(250, 250, 250, 0.5);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.preview-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.badge {
  background: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  box-shadow: var(--shadow-sm);
}

.preview-frame-wrapper {
  flex: 1;
  background: #525659;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
}

.preview-frame-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .editor-panel {
    flex-direction: column;
  }

  .controls-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .preview-container {
    height: 500px;
    border-radius: 0 0 var(--radius) var(--radius);
  }
}