/* ============================================================
   Chatbot TGT - Widget Styles
   ============================================================ */

:root {
    --tgt-primary: #0066FF;
    --tgt-primary-dark: #0052CC;
    --tgt-bg: #F5F7FA;
    --tgt-white: #FFFFFF;
    --tgt-text: #1A1A2E;
    --tgt-text-light: #6B7280;
    --tgt-border: #E5E7EB;
    --tgt-bot-bg: #EEF2FF;
    --tgt-user-bg: #0066FF;
    --tgt-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    --tgt-radius: 12px;
    --tgt-radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: transparent;
    color: var(--tgt-text);
    height: 100vh;
    overflow: hidden;
}

#tgt-chatbot {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Consent Screen --- */
.tgt-consent {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    background: var(--tgt-bg);
}

.tgt-consent-card {
    background: var(--tgt-white);
    border-radius: var(--tgt-radius);
    padding: 40px 32px;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--tgt-shadow);
}

.tgt-consent-icon {
    margin-bottom: 16px;
}

.tgt-consent-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--tgt-text);
}

.tgt-consent-card p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--tgt-text-light);
    margin-bottom: 16px;
}

.tgt-consent-legal {
    font-size: 12px !important;
    color: #9CA3AF !important;
}

.tgt-consent-legal a {
    color: var(--tgt-primary);
    text-decoration: none;
}

.tgt-consent-legal a:hover {
    text-decoration: underline;
}

/* --- Buttons --- */
.tgt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 32px;
    border: none;
    border-radius: var(--tgt-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tgt-btn-primary {
    background: var(--tgt-primary);
    color: white;
}

.tgt-btn-primary:hover {
    background: var(--tgt-primary-dark);
    transform: translateY(-1px);
}

.tgt-icon-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.tgt-icon-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* --- Chat Layout --- */
.tgt-chat {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--tgt-bg);
}

/* --- Header --- */
.tgt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--tgt-primary);
    color: white;
    flex-shrink: 0;
}

.tgt-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tgt-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tgt-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.tgt-status {
    font-size: 12px;
    opacity: 0.8;
}

.tgt-header-actions {
    display: flex;
    gap: 8px;
}

/* --- Messages --- */
.tgt-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tgt-message {
    display: flex;
    max-width: 85%;
    animation: tgt-fadeIn 0.3s ease;
}

@keyframes tgt-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.tgt-message-bot {
    align-self: flex-start;
}

.tgt-message-user {
    align-self: flex-end;
}

.tgt-message-bubble {
    padding: 12px 16px;
    border-radius: var(--tgt-radius);
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.tgt-message-bot .tgt-message-bubble {
    background: var(--tgt-white);
    color: var(--tgt-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.tgt-message-user .tgt-message-bubble {
    background: var(--tgt-user-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Markdown dentro de mensajes bot */
.tgt-message-bot .tgt-message-bubble p {
    margin: 0 0 10px 0;
}

.tgt-message-bot .tgt-message-bubble p:last-child {
    margin-bottom: 0;
}

.tgt-message-bot .tgt-message-bubble strong {
    font-weight: 700;
    color: var(--tgt-text);
}

.tgt-message-bot .tgt-message-bubble em {
    font-style: italic;
}

.tgt-message-bot .tgt-message-bubble ul,
.tgt-message-bot .tgt-message-bubble ol {
    margin: 8px 0 10px 0;
    padding-left: 22px;
}

.tgt-message-bot .tgt-message-bubble ul {
    list-style-type: disc;
}

.tgt-message-bot .tgt-message-bubble ol {
    list-style-type: decimal;
}

.tgt-message-bot .tgt-message-bubble li {
    margin-bottom: 8px;
    padding-left: 2px;
    line-height: 1.55;
}

.tgt-message-bot .tgt-message-bubble li:last-child {
    margin-bottom: 0;
}

.tgt-message-bot .tgt-message-bubble li strong {
    display: inline;
}

.tgt-message-bot .tgt-message-bubble code {
    background: #F3F4F6;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.tgt-message-bot .tgt-message-bubble ul + p,
.tgt-message-bot .tgt-message-bubble ol + p,
.tgt-message-bot .tgt-message-bubble p + ul,
.tgt-message-bot .tgt-message-bubble p + ol {
    margin-top: 10px;
}

.tgt-message-bot .tgt-message-bubble br {
    display: none;
}

/* Typing indicator */
.tgt-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.tgt-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tgt-text-light);
    animation: tgt-bounce 1.4s infinite ease-in-out both;
}

.tgt-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.tgt-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes tgt-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* --- Input Area --- */
.tgt-input-area {
    padding: 16px 20px;
    background: var(--tgt-white);
    border-top: 1px solid var(--tgt-border);
    flex-shrink: 0;
}

.tgt-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

#tgt-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--tgt-border);
    border-radius: var(--tgt-radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

#tgt-input:focus {
    border-color: var(--tgt-primary);
}

.tgt-send-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tgt-primary);
    color: white;
    border: none;
    border-radius: var(--tgt-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tgt-send-btn:hover:not(:disabled) {
    background: var(--tgt-primary-dark);
}

.tgt-send-btn:disabled {
    background: var(--tgt-border);
    cursor: not-allowed;
}

.tgt-powered {
    text-align: center;
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 8px;
}

/* --- Scrollbar --- */
.tgt-messages::-webkit-scrollbar {
    width: 6px;
}

.tgt-messages::-webkit-scrollbar-track {
    background: transparent;
}

.tgt-messages::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

/* --- Accessibility --- */
.tgt-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible para navegacion por teclado */
*:focus-visible {
    outline: 2px solid var(--tgt-primary);
    outline-offset: 2px;
}

.tgt-icon-btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Respetar preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Alto contraste */
@media (prefers-contrast: high) {
    .tgt-message-bot .tgt-message-bubble {
        border: 1px solid var(--tgt-text);
    }
    .tgt-message-user .tgt-message-bubble {
        border: 1px solid white;
    }
    #tgt-input {
        border-width: 2px;
    }
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .tgt-consent-card {
        padding: 24px 20px;
    }

    .tgt-message {
        max-width: 92%;
    }
}
