/* ===========================
   RESET & BASE
=========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #181c27;
  --surface2: #1e2333;
  --border: #2a2f45;
  --border-light: #323856;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-dim: rgba(99,102,241,0.15);
  --text: #e2e5f0;
  --text-muted: #8b91ad;
  --text-dim: #555c7a;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --sidebar-w: 220px;
  --transition: 0.18s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button { cursor: pointer; font-family: inherit; font-size: 13px; border: none; background: none; }
input, textarea { font-family: inherit; font-size: 13px; }
textarea { resize: vertical; }

/* ===========================
   LAYOUT
=========================== */
body { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), min-width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.sidebar-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.logo svg { color: var(--accent); flex-shrink: 0; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 8px 6px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 100%;
  text-align: left;
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  position: relative;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent-hover); }
.nav-item svg { flex-shrink: 0; }

.nav-count {
  margin-left: auto;
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

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

.nav-cat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 100%;
  text-align: left;
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.nav-cat-item:hover { background: var(--surface2); color: var(--text); }
.nav-cat-item.active { background: var(--accent-dim); color: var(--accent-hover); }

.cat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.btn-icon-text {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  width: 100%;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  cursor: pointer;
}

.btn-icon-text:hover { background: var(--surface2); color: var(--text); }

/* MAIN */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar-toggle {
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.sidebar-toggle:hover { background: var(--surface2); color: var(--text); }

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  max-width: 380px;
  color: var(--text-muted);
}

.search-wrap input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  width: 100%;
}

.search-wrap input::placeholder { color: var(--text-dim); }

/* CONTENT */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.content-area::-webkit-scrollbar { width: 6px; }
.content-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 18px;
  text-transform: capitalize;
}

/* GRID */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}

.card-preview {
  height: 200px;
  background: #fff;
  overflow: hidden;
  position: relative;
  border-bottom: 1px solid var(--border);
  pointer-events: none;
}

.card-preview iframe {
  width: 1280px;
  height: 800px;
  border: none;
  transform-origin: top left;
  pointer-events: none;
}

.card-info {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent-dim);
  color: var(--accent-hover);
  text-transform: capitalize;
}

.tag {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 20px;
}

.card-actions {
  display: flex;
  gap: 6px;
  padding: 0 14px 12px;
}

.btn-sm {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
}

/* BUTTONS */
.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: background var(--transition);
  white-space: nowrap;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--accent-dim); color: var(--accent); }

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
}

.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--green);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: opacity var(--transition);
}

.btn-copy:hover { opacity: 0.85; }
.btn-copy.copied { background: var(--accent); }

.btn-danger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(239,68,68,0.12);
  color: var(--red);
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: background var(--transition);
}

.btn-danger:hover { background: rgba(239,68,68,0.22); }

.close-btn {
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.close-btn:hover { background: var(--surface2); color: var(--text); }

/* EMPTY STATE */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  padding: 80px 20px;
}

.empty-state svg { opacity: 0.3; }
.empty-state p { font-size: 15px; }

/* ===========================
   MODALS
=========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.modal-form-inner { width: 100%; max-width: 720px; }
.modal-view-inner { width: 100%; max-width: 960px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.modal-header h2 { font-size: 16px; font-weight: 600; }

.view-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.view-title-wrap h2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.modal-body {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* FORM */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.label-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
}

.form-group input,
.form-group textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); }

.form-group textarea {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
}

/* VIEW TAGS */
.view-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 38px;
}

/* PREVIEW */
.preview-container {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.preview-frame-wrap {
  height: 280px;
  overflow: hidden;
  background: #fff;
  display: flex;
  justify-content: center;
  transition: all var(--transition);
}

.preview-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  transition: width var(--transition);
}

/* CODE SECTION */
.code-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.code-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.code-tab {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.code-tab:hover { color: var(--text-muted); }
.code-tab.active { color: var(--accent-hover); border-bottom-color: var(--accent); }

.code-panel {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
}

.code-panel::-webkit-scrollbar { width: 6px; }
.code-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.code-panel pre {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 700px) {
  .sidebar { position: absolute; z-index: 100; height: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .view-actions { gap: 4px; }
  .btn-copy span, .btn-ghost span { display: none; }
  .modal { max-width: 100%; border-radius: 0; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .preview-frame-wrap { height: 200px; }
}

/* ===========================
   TYPE TOGGLE (form)
=========================== */
.type-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  width: fit-content;
}

.type-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.type-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.type-btn.active { background: var(--accent); color: #fff; }

/* Elementor hint */
.elementor-hint {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: rgba(144,47,236,0.08);
  border: 1px solid rgba(144,47,236,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 8px;
}

.elementor-hint svg { color: #902fec; flex-shrink: 0; margin-top: 2px; }
.elementor-hint strong { color: var(--text); }

/* Elementor placeholder no card */
.card-preview-elementor {
  height: 200px;
  background: rgba(144,47,236,0.07);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: default;
}

.elementor-thumb-badge {
  width: 48px;
  height: 48px;
  background: rgba(144,47,236,0.18);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #902fec;
}

/* Elementor placeholder no view modal */
.elementor-view-placeholder {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: rgba(144,47,236,0.07);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ev-icon {
  width: 40px;
  height: 40px;
  background: rgba(144,47,236,0.18);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #902fec;
  flex-shrink: 0;
}

.elementor-view-placeholder p {
  font-size: 13px;
  color: var(--text-muted);
}

/* Botão Abrir Preview no modal */
.btn-preview-open {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: rgba(99,102,241,0.12);
  color: var(--accent-hover);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.btn-preview-open:hover {
  background: rgba(99,102,241,0.22);
  border-color: var(--accent);
}

/* ===========================
   AI GENERATION
=========================== */
.btn-ai {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  transition: opacity var(--transition);
  white-space: nowrap;
}
.btn-ai:hover { opacity: 0.85; }
.btn-ai:disabled { opacity: 0.5; cursor: not-allowed; }

.modal-ai-inner { width: 100%; max-width: 760px; }

.ai-prompt-input {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
}

.ai-result-fields {
  flex-shrink: 0;
  padding-bottom: 12px;
}

.ai-preview-wrap {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-preview-wrap .preview-frame-wrap {
  height: 340px;
}

/* ===========================
   LOGIN PAGE
=========================== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--accent);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 32px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  width: 100%;
  padding-right: 42px;
}

.toggle-pass {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}

.toggle-pass:hover { color: var(--text-muted); }

.login-error {
  font-size: 13px;
  color: var(--red);
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  text-align: center;
}

.btn-login {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  transition: background var(--transition), opacity var(--transition);
  margin-top: 4px;
}

.btn-login:hover:not(:disabled) { background: var(--accent-hover); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }
