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

:root {
    --color-primary: #06b6d4;
    --color-primary-dark: #0891b2;
    --color-accent: #a855f7;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background:
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(6, 182, 212, 0.25) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(168, 85, 247, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse 50% 30% at 50% 50%, rgba(34, 211, 238, 0.1) 0%, transparent 60%),
        linear-gradient(160deg, #e0f2fe 0%, #f0f9ff 30%, #fce7f3 60%, #e0e7ff 100%);
    min-height: 100vh;
    padding: 2rem;
    color: #333;
}

body.chat-active {
    padding: 0;
}

.container {
    max-width: 700px;
    margin: 0 auto;
}

.container.chat-active {
    width: 900px;
    max-width: 100%;
    height: 80vh;
    margin: 0 auto;
    padding: 30px 0;
}

.container.chat-active .card {
    height: 100%;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow: hidden;
}

.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2), 0 0 0 1px rgba(6, 182, 212, 0.1);
    padding: 2rem;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--color-primary-dark);
}

.subtitle {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}

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

.form-group { margin-bottom: 1.25rem; }

.api-key-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.api-key-input-wrap .config-select { flex: 1; min-width: 200px; }
.api-key-badge {
    display: inline-block;
    background: #059669;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    white-space: nowrap;
}

/* Badge tipo de cuenta en Mi cuenta */
.account-type-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    padding: 0.9rem 1.25rem;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.account-type-badge__name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
}
.account-type-badge__detail {
    font-size: 0.85rem;
    opacity: 0.95;
    font-weight: 500;
}
.account-type-badge--none {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    box-shadow: 0 4px 14px rgba(100, 116, 139, 0.25);
}


.newsletter-checkbox {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
    margin-top: 0.2rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 17px;
}

.checkbox-label a {
    font-size: inherit;
}

.checkbox-label--center {
    align-items: center;
}

.footer-credits {
    text-align: center;
    margin-top: 1rem;
    color: #64748b;
    font-size: 0.85rem;
}

.footer-credits a {
    color: #64748b;
}

.footer-contratar-link {
    font-size: 20px;
    font-weight: bold;
    text-decoration: none;
    padding-bottom: 20px;
}

.footer-credits a[href*="humano.app"] {
    text-decoration: underline;
}

.required { color: var(--color-primary); }

.hint { font-size: 0.85rem; color: #888; margin-top: 0.25rem; }

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: opacity 0.2s, transform 0.1s;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:disabled { background: #94a3b8; cursor: not-allowed; opacity: 1; transform: none; }

.error { color: #c00; font-size: 0.9rem; margin-top: 0.25rem; }

#consultor-chat {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

#consultor-chat.visible {
    display: flex;
}

#consultor-form.hidden { display: none; }

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.msg { margin-bottom: 1rem; }

.msg-user { text-align: right; }

.msg-bubble {
    display: inline-block;
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
}

.msg-user .msg-bubble {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

.msg-assistant .msg-bubble {
    background: #fff;
    border: 1px solid rgba(6, 182, 212, 0.2);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.chat-form { display: flex; gap: 0.5rem; flex-shrink: 0; align-items: center; }

.chat-form textarea {
    flex: 1;
    min-height: 100px;
    padding: 0.75rem;
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

.chat-form .btn { width: auto; padding: 0.75rem 1.25rem; flex-shrink: 0; }

.chat-input-hint {
    font-size: 0.8rem;
    color: #94a3b8;
    margin: 0.5rem 0 0 0;
}

.msg-rate-block {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}
.msg-rate-label {
    font-size: 0.85rem;
    color: #64748b;
}
.msg-rate-stars {
    display: flex;
    gap: 0.1rem;
}
.msg-rate-stars .star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: #cbd5e1;
    padding: 0;
    line-height: 1;
    transition: color 0.2s, transform 0.1s;
}
.msg-rate-stars .star-btn:hover,
.msg-rate-stars .star-btn.filled {
    color: #fbbf24;
}
.msg-rate-stars .star-btn:hover { transform: scale(1.1); }
.msg-rate-thanks {
    font-size: 0.9rem;
    color: var(--color-primary-dark);
    font-weight: 500;
}
.msg-rate-thanks.hidden { display: none !important; }

/* Enlace reunión de consultoría - bloque separado */
.msg-meeting-block {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.08) 0%, rgba(6, 182, 212, 0.04) 100%);
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: 12px;
}
.msg-meeting-block::before {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.3), transparent);
    margin: -0.25rem 0 0.75rem 0;
}
.msg-meeting-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}
.msg-meeting-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.45);
}
.msg-meeting-link::before {
    content: '📅';
    font-size: 1.2em;
}

.loading { opacity: 0.8; }

.chat-title {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    color: var(--color-primary-dark);
    font-weight: 600;
}

/* Estilos para Markdown en mensajes del asistente */
.msg-content h1, .msg-content h2, .msg-content h3 {
    margin: 0.75em 0 0.5em;
    font-weight: 600;
    line-height: 1.3;
}
.msg-content h1 { font-size: 1.2em; }
.msg-content h2 { font-size: 1.1em; }
.msg-content h3 { font-size: 1em; }
.msg-content h1:first-child, .msg-content h2:first-child, .msg-content h3:first-child { margin-top: 0; }

.msg-content p { margin: 0.5em 0; line-height: 1.5; }
.msg-content p:first-child { margin-top: 0; }
.msg-content p:last-child { margin-bottom: 0; }

.msg-content ul, .msg-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}
.msg-content li { margin: 0.25em 0; }

.msg-content strong { font-weight: 600; }
.msg-content em { font-style: italic; }

.msg-content code {
    background: rgba(6, 182, 212, 0.12);
    color: var(--color-primary-dark);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    border: 1px solid rgba(6, 182, 212, 0.15);
}
.msg-content pre {
    background: rgba(6, 182, 212, 0.08);
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5em 0;
    border: 1px solid rgba(6, 182, 212, 0.15);
}
.msg-content pre code {
    background: none;
    padding: 0;
}

.msg-content blockquote {
    border-left: 4px solid var(--color-primary);
    margin: 0.5em 0;
    padding-left: 1em;
    color: #555;
    background: rgba(6, 182, 212, 0.05);
    padding: 0.5em 1em;
    border-radius: 0 8px 8px 0;
}

.msg-content hr { border: none; border-top: 1px solid rgba(6, 182, 212, 0.3); margin: 1em 0; }

.msg-user .msg-content code,
.msg-user .msg-content pre { background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.3); }

/* Admin */
.admin .container { max-width: 1100px; }

/* Botón flotante WhatsApp - Ayuda */
.admin-whatsapp-float {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: #25d366;
    color: #fff;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 9999;
}
.admin-whatsapp-float:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.5);
    color: #fff;
}
.admin-whatsapp-float svg {
    flex-shrink: 0;
}
.admin-nav { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.admin-nav a, .admin-nav button { padding: 0.5rem 1rem; background: #e2e8f0; border: none; border-radius: 8px; cursor: pointer; text-decoration: none; color: #333; font-size: 0.95rem; }
.admin-nav a:hover, .admin-nav button:hover { background: var(--color-primary); color: #fff; }
.admin-nav a.active { background: var(--color-primary); color: #fff; }
.admin-section { display: none; }
.admin-section.active { display: block; }
.section-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.admin-header h2 { margin: 0; }
.admin-header-actions { display: flex; align-items: center; gap: 0.5rem; }
.admin-header-actions a { text-decoration: none; }
.admin-header-actions .btn-icon-home { display: inline-flex; align-items: center; gap: 0.4rem; }
.admin-header-actions .btn-icon-home svg { flex-shrink: 0; }
.admin table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.admin th, .admin td { padding: 0.75rem; text-align: left; border-bottom: 1px solid #e2e8f0; }
.admin th { background: #f8fafc; font-weight: 600; }
.config-textarea {
    min-height: 200px;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    resize: vertical;
}
.config-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}
.config-form .form-group { margin-bottom: 1rem; }
.config-form label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.config-form .config-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.config-form .config-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}
.config-form textarea.config-select {
    min-height: 80px;
    resize: vertical;
}
.admin .config-select { padding: 0.5rem; }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.85rem; width: auto; }
.btn-link {
    background: none !important;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    padding: 0.25rem 0;
    font-size: 0.9rem;
    text-decoration: underline;
}
.btn-link:hover { opacity: 0.8; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { opacity: 0.9; }
.text-muted { color: #64748b; font-size: 0.9rem; }
.admin .text-muted { margin-top: 0.25rem; }
.admin .card input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; cursor: pointer; }
.admin .checkbox-inline { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.collapse-text { max-height: 80px; overflow: hidden; }
.collapse-text.expanded { max-height: none; }
.toggle-expand { cursor: pointer; color: var(--color-primary); font-size: 0.85rem; }
.admin.provider-claude .form-group.api-provider-chatgpt { display: none; }
.admin.provider-chatgpt .form-group.api-provider-claude { display: none; }
.admin .newsletter-text-group { margin-top: 0.5rem; }
.hidden { display: none !important; }
.admin .newsletter-text-group.hidden { display: none !important; }

/* Bloques de formulario en Privacidad y formulario */
.admin .section-intro {
    color: #64748b;
    font-size: 0.95rem;
    margin: -0.25rem 0 1.5rem 0;
    max-width: 42rem;
}
.admin .form-block {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem 1.5rem 1.25rem;
    margin-bottom: 1.5rem;
}
.admin .form-block:last-of-type { margin-bottom: 1rem; }
.admin .form-block__title {
    margin: 0 0 0.25rem 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
}
.admin .form-block__desc {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    color: #64748b;
}
.admin .form-block .form-group { margin-bottom: 1rem; }
.admin .form-block .form-group:last-child { margin-bottom: 0; }
.admin .form-privacidad__actions {
    padding-top: 0.5rem;
}

.impersonate-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

/* Newsletter API icon en tabla usuarios */
.newsletter-api-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}
.newsletter-api-icon:hover { opacity: 0.8; }
.newsletter-api-icon--ok { background: #22c55e; color: #fff; }
.newsletter-api-icon--ko { background: #ef4444; color: #fff; }

/* Modal respuesta newsletter */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-content {
    background: #fff;
    border-radius: 12px;
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}
.modal-header h4 { margin: 0; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
}
.modal-close:hover { color: #1e293b; }
.modal-body {
    padding: 1rem 1.25rem;
    overflow: auto;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.modal-conversacion { max-width: 640px; width: 95%; }
.conversacion-chat {
    padding: 1rem 1.25rem;
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.conversacion-chat .msg { margin: 0; }
.admin .form-add-admin-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.admin .form-add-admin-row input[type="email"] { flex: 1; min-width: 200px; }
.admin .form-add-admin-row input[type="password"] { flex: 1; min-width: 150px; }
.admin .form-add-admin { margin-bottom: 1.5rem; }
.admin .tokens-summary { margin-bottom: 1rem; }
.pagination { margin-top: 1rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.admin-back { text-align: center; margin-top: 1rem; }
.admin-back a { color: #64748b; }

/* Login admin */
.admin-login { max-width: 400px; margin: 4rem auto; }
.admin-login h1 { text-align: center; margin-bottom: 1.5rem; }
.admin-login .error { background: #fee; color: #c00; padding: 0.75rem; border-radius: 8px; margin-bottom: 1rem; }

/* Cabecera de sección con ayuda a la derecha */
.admin .section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.admin .section-header-row h3 { margin: 0; }

/* Enlace ayuda prompt: recuadro amarillento con icono i */
.help-prompt-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
    border: 1px solid #eab308;
    border-radius: 8px;
    color: #854d0e;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: opacity 0.2s, box-shadow 0.2s;
}
.help-prompt-link:hover {
    opacity: 0.9;
    box-shadow: 0 2px 8px rgba(234, 179, 8, 0.25);
}
.help-prompt-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    background: #ca8a04;
    color: #fff;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    font-style: italic;
}

/* Bloques con margen extra */
.form-block.form-block--mt { margin-top: 1.5rem; }
.form-block.form-block--mt-sm { margin-top: 1rem; }

/* Toast / notificación bonita */
#notify-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.notify-toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.notify-toast--visible {
    opacity: 1;
    transform: translateY(0);
}

.notify-toast--success {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #fff;
}

.notify-toast--error {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: #fff;
}

.notify-icon {
    font-size: 1.2rem;
    font-weight: bold;
}
