/* =========================================================
   LTM Digital SaaS — Dashboard CSS
   ========================================================= */

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

:root {
  --bg: #080c14;
  --bg-surface: #0d1525;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --accent: #C5A880;
  --accent-dark: #9a7a5a;
  --accent-glow: rgba(197,168,128,0.2);
  --green: #4ade80;
  --red: #f87171;
  --yellow: #fbbf24;
  --text: #f0ece6;
  --text-muted: rgba(240,236,230,0.5);
  --text-dim: rgba(240,236,230,0.3);
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --font: 'Inter', sans-serif;
  --font-h: 'Outfit', sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 1.5rem 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-text {
  font-family: var(--font-h);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.logo-text span { color: var(--accent); }

.version-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(197,168,128,0.15);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(197,168,128,0.3);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-bottom {
  padding: 0.8rem 0.6rem 1.2rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item, .logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover, .logout-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.nav-icon { font-size: 1rem; flex-shrink: 0; }

/* MAIN WRAP */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  display: none;
}

.topbar-title {
  font-family: var(--font-h);
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}

.topbar-user {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
}

.view-container {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  width: 100%;
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.8rem;
}

.view-header h2 {
  font-family: var(--font-h);
  font-size: 1.5rem;
  font-weight: 600;
}

.view-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* MAGIC IMPORTER CARD */
.magic-importer-card {
  background: linear-gradient(135deg, rgba(197,168,128,0.12), rgba(255,255,255,0.03));
  border: 1px solid rgba(197,168,128,0.3);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.magic-importer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1rem;
}

.magic-icon {
  font-size: 1.8rem;
  background: rgba(197,168,128,0.2);
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
}

.magic-title {
  font-family: var(--font-h);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.magic-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.magic-input-wrap {
  display: flex;
  gap: 10px;
}

.magic-input-wrap input {
  flex: 1;
  background: rgba(8,12,20,0.6);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.92rem;
  padding: 0.85rem 1.1rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.magic-input-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.magic-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-h);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0 1.5rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.magic-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }

.magic-status {
  font-size: 0.85rem;
  margin-top: 0.8rem;
}
.magic-status .status-ok { color: var(--green); }
.magic-status .status-err { color: var(--red); }

/* STATS GRID */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--border-hover); }
.stat-card.warn { border-color: rgba(251,191,36,0.25); }
.stat-card.warn .stat-value { color: var(--yellow); }

.stat-icon { font-size: 1.8rem; }

.stat-value {
  font-family: var(--font-h);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* PREVIEWS LIST */
.section-title {
  font-family: var(--font-h);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
}

.previews-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color var(--transition), background var(--transition);
}

.preview-card:hover { background: var(--surface-hover); border-color: var(--border-hover); }

.preview-card-main { flex: 1; min-width: 0; }

.preview-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

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

.preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-active { background: rgba(74,222,128,0.1); color: var(--green); border: 1px solid rgba(74,222,128,0.2); }
.badge-archived { background: rgba(255,255,255,0.06); color: var(--text-muted); border: 1px solid var(--border); }
.badge-expiring { background: rgba(251,191,36,0.1); color: var(--yellow); border: 1px solid rgba(251,191,36,0.25); }

/* BUTTONS */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-h);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 12px var(--accent-glow);
  white-space: nowrap;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); }
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }
.btn-icon.danger:hover { background: rgba(248,113,113,0.1); color: var(--red); border-color: rgba(248,113,113,0.3); }

/* FORM CARDS */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.form-card h3 {
  font-family: var(--font-h);
  font-size: 1.05rem;
  font-weight: 600;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 0.78rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.subdomain-wrap { display: flex; align-items: center; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.subdomain-wrap input { border: none !important; background: none !important; }
.sub-suffix { font-size: 0.8rem; color: var(--accent); padding-right: 0.9rem; font-weight: 600; white-space: nowrap; }

.input-group input, .input-group textarea, .input-group select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.7rem 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.input-group input:focus, .input-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.field-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

/* BRAND COLOR & CONTRAST */
.brand-color-wrap { display: flex; align-items: center; gap: 8px; }
.brand-color-wrap input[type="text"] { flex: 1; }

#f-brandColorPicker {
  -webkit-appearance: none;
  width: 40px; height: 40px;
  border: none; border-radius: 50%;
  cursor: pointer; background: none; flex-shrink: 0;
}
#f-brandColorPicker::-webkit-color-swatch-wrapper { padding: 0; }
#f-brandColorPicker::-webkit-color-swatch { border-radius: 50%; border: 2px solid var(--border); }

.contrast-indicator {
  font-size: 0.78rem; padding: 6px 10px;
  border-radius: 8px; margin-top: 4px;
  border: 1px solid transparent;
  transition: all 0.3s;
}
.contrast-indicator.pass-aa { background: rgba(74,222,128,0.08); color: var(--green); border-color: rgba(74,222,128,0.2); }
.contrast-indicator.pass-aaa { background: rgba(74,222,128,0.12); color: #86efac; border-color: rgba(74,222,128,0.3); }
.contrast-indicator.warn { background: rgba(251,191,36,0.08); color: var(--yellow); border-color: rgba(251,191,36,0.2); }
.contrast-indicator.fail { background: rgba(248,113,113,0.08); color: var(--red); border-color: rgba(248,113,113,0.2); }

.palette-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.preset-btn {
  border: 2px solid transparent; border-radius: 10px;
  color: #fff; font-size: 0.75rem; font-weight: 700;
  padding: 8px 14px; cursor: pointer;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  transition: transform var(--transition);
}
.preset-btn:hover { transform: scale(1.04); }

.toggle-link {
  background: none; border: none; color: var(--text-muted);
  font-size: 0.78rem; cursor: pointer; text-decoration: underline;
}
.toggle-link:hover { color: var(--accent); }

.color-customizer {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
}

.color-picker-group { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.color-picker-group label { font-size: 0.72rem; color: var(--text-muted); }
.color-picker-group input[type="color"] {
  width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid var(--border); cursor: pointer;
  -webkit-appearance: none; padding: 2px;
  background: none;
}
.color-picker-group input[type="color"]::-webkit-color-swatch { border-radius: 7px; }

/* DROPZONES */
.upload-section { display: flex; flex-direction: column; gap: 8px; }
.file-dropzone {
  background: rgba(255,255,255,0.03);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.file-dropzone:hover { border-color: var(--accent); background: var(--accent-glow); }
.file-dropzone label { font-size: 0.75rem; color: var(--text-muted); display: block; margin-bottom: 4px; cursor: pointer; }
.file-dropzone input[type="file"] { opacity: 0; position: absolute; pointer-events: none; }
.dropzone-label { font-size: 0.85rem; color: var(--text-dim); }
.file-dropzone.has-file { border-style: solid; border-color: var(--green); }
.file-dropzone.has-file .dropzone-label { color: var(--green); font-weight: 600; }

.prompt-box { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prompt-copy-btn {
  background: var(--surface-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 0.8rem; font-weight: 500; padding: 0.65rem;
  cursor: pointer; transition: all var(--transition);
}
.prompt-copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.prompt-copy-btn.copied { background: rgba(74,222,128,0.1); color: var(--green); border-color: var(--green); }

.action-buttons { display: flex; gap: 10px; margin-top: 0.5rem; }
.action-buttons .btn-primary { flex: 1; padding: 0.85rem; font-size: 0.95rem; }
.preview-btn-sm {
  background: var(--surface-hover); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 0.9rem; font-weight: 500; padding: 0.85rem 1.2rem;
  cursor: pointer; transition: all var(--transition);
}
.preview-btn-sm:hover { border-color: var(--accent); color: var(--text); }

.settings-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 1.5rem; }
.settings-msg { font-size: 0.85rem; margin-top: 0.7rem; }
.settings-msg.success { color: var(--green); }
.settings-msg.error { color: var(--red); }

/* PREVIEW PANEL */
.preview-panel {
  position: fixed;
  bottom: 0; left: var(--sidebar-w); right: 0;
  height: 60vh;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  z-index: 150;
  display: flex; flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.4);
}
.preview-panel.hidden { display: none; }

.preview-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1.5rem; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.9rem;
}

.preview-size-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-muted);
  font-size: 0.78rem; padding: 4px 10px; cursor: pointer;
}
.preview-size-btn.active { color: var(--accent); border-color: var(--accent); }

.iframe-wrap {
  flex: 1; overflow: hidden;
  display: flex; justify-content: center;
  background: #ccc;
  width: 100%;
}
#preview-iframe { width: 100%; height: 100%; border: none; }

/* LOADER & TOAST */
.loader-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(8,12,20,0.85); backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
}
.loader-overlay.hidden { display: none; }

.loader-content {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1.2rem;
}

.spinner {
  width: 52px; height: 52px;
  border: 3px solid rgba(255,255,255,0.05);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.loader-content h3 { font-family: var(--font-h); font-size: 1.1rem; font-weight: 500; }
.loader-sub { font-size: 0.82rem; color: var(--text-muted); }

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

.toast {
  position: fixed;
  bottom: 2rem; right: 2rem;
  background: #1a2535;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.5rem;
  font-size: 0.88rem; font-weight: 500;
  z-index: 600;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  animation: slideUp 0.3s ease;
}
.toast.hidden { display: none; }
.toast.success { border-color: rgba(74,222,128,0.4); color: var(--green); }
.toast.error { border-color: rgba(248,113,113,0.4); color: var(--red); }

.hidden { display: none !important; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .preview-panel { left: 0; }
  .settings-grid { grid-template-columns: 1fr; }
  .magic-input-wrap { flex-direction: column; }
}
