/* ============================================================
   Pulso Design System - creativos.novaecom.io
   Electric orange #ff5b04, Bricolage Grotesque, JetBrains Mono
   Soporte dark/light mode vía [data-theme]
   ============================================================ */

/* ---------- Variables de tema ---------- */
:root {
    /* Colores marca */
    --brand: #ff5b04;
    --brand-hover: #ff7427;
    --brand-glow: rgba(255, 91, 4, 0.15);

    /* Tipografía */
    --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Espaciado */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.15);

    /* Transiciones */
    --transition: 180ms ease;
}

/* Dark theme (default) */
[data-theme="dark"] {
    --bg: #0a0a0b;
    --bg-elev: #131316;
    --bg-elev-2: #1c1c20;
    --border: #2a2a30;
    --border-strong: #3a3a42;
    --text: #f5f5f7;
    --text-dim: #a1a1aa;
    --text-faint: #6b6b75;
    --danger: #ff4757;
    --success: #00d68f;
}

/* Light theme */
[data-theme="light"] {
    --bg: #fafafa;
    --bg-elev: #ffffff;
    --bg-elev-2: #f4f4f6;
    --border: #e5e5ea;
    --border-strong: #d4d4d8;
    --text: #18181b;
    --text-dim: #52525b;
    --text-faint: #a1a1aa;
    --danger: #e02943;
    --success: #00a86b;
}

/* ---------- Reset y base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-display);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    transition: background var(--transition);
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 32px; }

.brand {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.02em;
    color: var(--text);
}
.brand-dot { color: var(--brand); }
.brand-domain { color: var(--text-faint); font-weight: 500; }

.tabs { display: flex; gap: 4px; }

.tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition);
}
.tab:hover { color: var(--text); background: var(--bg-elev-2); }
.tab.active { color: var(--brand); background: var(--brand-glow); }

.icon-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-elev-2); }

/* ---------- Layout main ---------- */
#app { padding: 28px; max-width: 1400px; margin: 0 auto; }

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

.view-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.view-subtitle { color: var(--text-dim); margin-top: 4px; font-size: 14px; }

/* ---------- Botones ---------- */
.btn {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    border: 1px solid transparent;
}
.btn-primary {
    background: var(--brand);
    color: #ffffff;
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg-elev-2);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--border-strong); }

.btn-ghost { color: var(--text-dim); padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); background: var(--bg-elev-2); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(255, 71, 87, 0.1); }

/* ---------- Cards (lista de productos) ---------- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
    cursor: pointer;
}
.card:hover {
    border-color: var(--brand);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}
.card-meta {
    font-size: 12px;
    color: var(--text-faint);
    font-family: var(--font-mono);
    margin-bottom: 12px;
}
.card-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}
.card-stat strong { color: var(--text); }

/* ---------- Formularios ---------- */
.form-row { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}
.form-textarea { font-family: var(--font-mono); font-size: 13px; resize: vertical; min-height: 80px; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

/* ---------- Vista de generar (formulario + resultado) ---------- */
.generar-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .generar-layout { grid-template-columns: 1fr; }
}

.panel {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.panel-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 16px;
}

/* Bloques de prompts generados */
.prompt-block {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
}
.prompt-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.prompt-block-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--brand);
    font-family: var(--font-mono);
}
.prompt-block-text {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.copy-btn {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    transition: var(--transition);
}
.copy-btn:hover { color: var(--brand); border-color: var(--brand); }
.copy-btn.copied { color: var(--success); border-color: var(--success); }

/* Imagen generada */
.imagen-preview {
    aspect-ratio: 9/16;
    background: var(--bg-elev-2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
    font-size: 13px;
    overflow: hidden;
    max-width: 320px;
    margin: 0 auto 16px;
}
.imagen-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Tablas (historial) ---------- */
.table {
    width: 100%;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.table th {
    background: var(--bg-elev-2);
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.04em;
}
.table td.mono { font-family: var(--font-mono); font-size: 12px; }
.table tr:hover { background: var(--bg-elev-2); }
.table tr:last-child td { border-bottom: none; }

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
}
.badge-prompts { background: rgba(161, 161, 170, 0.15); color: var(--text-dim); }
.badge-image { background: rgba(0, 214, 143, 0.15); color: var(--success); }
.badge-failed { background: rgba(255, 71, 87, 0.15); color: var(--danger); }

/* ---------- Toasts ---------- */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}
.toast {
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    box-shadow: var(--shadow-md);
    font-size: 14px;
    min-width: 240px;
    animation: slideIn 200ms ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--brand); }

@keyframes slideIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
}
.modal-overlay.hidden { display: none; }
.modal-content {
    background: var(--bg-elev);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

/* ---------- Utilidades ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.mt-md { margin-top: 16px; }
.mb-md { margin-bottom: 16px; }
.text-dim { color: var(--text-dim); }
.text-mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

/* Loader spinner */
.spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--bg-elev-2);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-faint);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
