/* ══════════════════════════════════════════════════════════════
   MEMORIA PERMANENTE
   ══════════════════════════════════════════════════════════════ */

.memory-create-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.memory-create-form input[type="text"],
.memory-create-form textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}
.memory-create-form input:focus,
.memory-create-form textarea:focus { border-color: var(--accent); outline: none; }

.memory-create-form textarea {
    min-height: 70px;
    resize: vertical;
    line-height: 1.5;
}

.memory-create-form button {
    align-self: flex-end;
    padding: 8px 16px;
}

.memory-item {
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: opacity 0.2s;
}
.memory-item.inactive { opacity: 0.45; }

.memory-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.memory-cat {
    font-size: 10px;
    padding: 2px 8px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.memory-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
    cursor: pointer;
}
.memory-toggle input { accent-color: var(--accent); }

.memory-del {
    padding: 4px 8px;
    color: var(--text-muted);
    border-radius: 4px;
    font-size: 14px;
}
.memory-del:hover { color: var(--danger); background: rgba(239,83,80,0.1); }

.memory-content {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.55;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: text;
    transition: background 0.15s;
}
.memory-content:hover { background: rgba(255,255,255,0.03); }
.memory-content.editing {
    background: var(--bg-primary);
    outline: 1px solid var(--accent);
}

/* ══════════════════════════════════════════════════════════════
   PLANTILLAS — Cards en la pantalla de bienvenida
   ══════════════════════════════════════════════════════════════ */

.templates-welcome {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 24px;
    width: 100%;
    max-width: 640px;
}

.template-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    font-family: inherit;
}
.template-card:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.tc-icon {
    font-size: 20px;
    flex-shrink: 0;
}
.tc-name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .templates-welcome {
        grid-template-columns: 1fr;
        gap: 8px;
        max-width: 100%;
    }
    .template-card { padding: 12px 14px; }
}

/* ══════════════════════════════════════════════════════════════
   PLANTILLAS — Picker modal
   ══════════════════════════════════════════════════════════════ */

#templates-picker {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#templates-picker.hidden { display: none; }

.templates-picker-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 520px;
    max-width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.templates-picker-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.templates-picker-header h3 {
    font-size: 15px;
    color: var(--text-primary);
}
.templates-picker-header button {
    padding: 6px 12px;
    color: var(--text-muted);
    font-size: 14px;
    border-radius: var(--radius-xs);
}
.templates-picker-header button:hover { background: var(--bg-hover); color: var(--text-primary); }

#templates-picker-list {
    overflow-y: auto;
    padding: 10px;
    flex: 1;
}

.template-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    margin-bottom: 4px;
    font-family: inherit;
    color: var(--text-primary);
}
.template-picker-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.tpi-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.tpi-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}
.tpi-text strong {
    font-size: 13px;
    font-weight: 600;
}
.tpi-text span {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════
   PLANTILLAS — Listado en Ajustes
   ══════════════════════════════════════════════════════════════ */

.template-settings-item {
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.tsi-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.tsi-icon { font-size: 18px; }

.tsi-header strong {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

.tsi-actions {
    display: flex;
    gap: 6px;
}

.tsi-actions button {
    padding: 4px 10px;
    font-size: 11px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}
.tsi-actions button:hover { background: var(--bg-hover); color: var(--text-primary); }
.tsi-actions button.danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(239,83,80,0.1); }

.tsi-content {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    padding: 6px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Formulario de plantilla */
#template-form {
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}
#template-form.hidden { display: none; }

#template-form h4 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

#template-form .s-field {
    margin-bottom: 12px;
}
#template-form label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
#template-form input[type="text"],
#template-form textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}
#template-form input:focus,
#template-form textarea:focus { border-color: var(--accent); outline: none; }
#template-form textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}

#tf-icon { width: 60px !important; text-align: center; font-size: 18px !important; }
