/* ============================================
   Launchly — Shared Application Styles
   Design tokens from landing page
   ============================================ */

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

:root {
  --bg: #0a0a0f;
  --bg-card: #12121a;
  --bg-subtle: #1a1a26;
  --bg-hover: #1e1e2e;
  --text: #f0f0f5;
  --text-muted: #8888a0;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --green: #00d2a0;
  --orange: #fdcb6e;
  --pink: #fd79a8;
  --red: #e74c3c;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(108,92,231,0.3);
  --radius: 12px;
  --radius-lg: 16px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top Navigation ---- */
.app-nav {
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.app-nav .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  text-decoration: none;
}
.app-nav .logo span { color: var(--accent-light); }

.app-nav .nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-nav .nav-user {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: #5b4bd5;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(108,92,231,0.3);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.btn-danger {
  background: rgba(231, 76, 60, 0.15);
  color: var(--red);
  border: 1px solid rgba(231, 76, 60, 0.2);
}
.btn-danger:hover {
  background: rgba(231, 76, 60, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-subtle); }

.btn-sm { padding: 0.4rem 1rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ---- Form Elements ---- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.2s;
  outline: none;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.1);
}
.form-input::placeholder { color: rgba(136,136,160,0.5); }

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

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color 0.3s;
}
.card:hover { border-color: var(--border-hover); }

/* ---- Container ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.container-sm {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem;
}

/* ---- Auth Pages ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.auth-card .logo-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-card .logo-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.auth-card .logo-header h1 span { color: var(--accent-light); }
.auth-card .logo-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.auth-card .btn-primary {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.auth-card .footer-link {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.error-msg {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.2);
  color: var(--red);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}
.error-msg.show { display: block; }

/* ---- Dashboard ---- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -1px;
}

.website-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.website-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.3s;
  cursor: pointer;
}
.website-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.website-card .preview {
  height: 160px;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.website-card .preview .template-icon {
  font-size: 3rem;
  opacity: 0.3;
}
.website-card .preview .status-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-badge.draft {
  background: rgba(136,136,160,0.15);
  color: var(--text-muted);
  border: 1px solid rgba(136,136,160,0.2);
}
.status-badge.published {
  background: rgba(0,210,160,0.15);
  color: var(--green);
  border: 1px solid rgba(0,210,160,0.2);
}

.website-card .info {
  padding: 1.25rem;
}
.website-card .info h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.website-card .info .subdomain {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.website-card .info .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
}
.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}
.empty-state h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.empty-state p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  padding: 1rem;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Template picker */
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.template-option {
  background: var(--bg-subtle);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.template-option:hover { border-color: var(--border-hover); }
.template-option.selected { border-color: var(--accent); background: rgba(108,92,231,0.08); }
.template-option .t-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  display: block;
}
.template-option .t-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}
.template-option .t-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---- Editor ---- */
.editor-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: calc(100vh - 57px);
}

.editor-sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--bg-card);
}

.editor-sidebar .sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.editor-sidebar .sidebar-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.section-list {
  padding: 0.75rem;
}

.section-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  transition: all 0.2s;
  cursor: grab;
}
.section-item:active { cursor: grabbing; }
.section-item.dragging {
  opacity: 0.5;
  transform: scale(0.98);
}
.section-item.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108,92,231,0.2);
}
.section-item.editing {
  border-color: var(--accent);
}

.section-item .section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
}
.section-item .drag-handle {
  color: var(--text-muted);
  font-size: 1rem;
  cursor: grab;
  flex-shrink: 0;
}
.section-item .section-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-light);
  background: rgba(108,92,231,0.12);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}
.section-item .section-title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.section-item .section-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.section-item:hover .section-actions { opacity: 1; }
.section-item .section-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.85rem;
  border-radius: 4px;
}
.section-item .section-actions button:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.section-item .section-actions button.delete:hover { color: var(--red); }

.section-editor {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: none;
}
.section-item.editing .section-editor { display: block; }

.section-editor .form-group { margin-bottom: 0.75rem; }
.section-editor .form-label { font-size: 0.75rem; margin-bottom: 0.35rem; }
.section-editor .form-input { font-size: 0.85rem; padding: 0.55rem 0.75rem; }

/* Section editor — items list */
.items-list .item-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}
.items-list .item-entry .form-input { margin-bottom: 0.35rem; }
.items-list .item-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.35rem;
}

.add-item-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  width: 100%;
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}
.add-item-btn:hover { border-color: var(--accent); color: var(--accent-light); }

/* Preview panel */
.editor-preview {
  overflow-y: auto;
  background: var(--bg);
}

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

/* Editor top bar */
.editor-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.editor-topbar .left { display: flex; align-items: center; gap: 1rem; }
.editor-topbar .site-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
}
.editor-topbar .right { display: flex; align-items: center; gap: 0.75rem; }

/* Add section panel */
.add-section-panel {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}
.add-section-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
.add-section-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
}
.add-section-btn:hover { border-color: var(--accent); background: rgba(108,92,231,0.08); }
.add-section-btn .icon { font-size: 1.2rem; margin-bottom: 0.25rem; display: block; }
.add-section-btn .label { font-size: 0.75rem; color: var(--text-muted); }

/* ---- Utilities ---- */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }

/* ---- Loading ---- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-preview { display: none; }
  .template-grid { grid-template-columns: 1fr; }
  .website-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
  .container { padding: 1rem; }
}
