/* ========================================
   FARMACIA ASISTENTE - Estilos Minimalistas
   ======================================== */

:root {
    --primary: #2E7D32;
    --primary-light: #4CAF50;
    --primary-dark: #1B5E20;
    --accent: #00897B;
    --bg: #F5F7FA;
    --bg-chat: #FAFBFC;
    --white: #FFFFFF;
    --text: #263238;
    --text-muted: #78909C;
    --user-bubble: #2E7D32;
    --bot-bubble: #FFFFFF;
    --border: #E8ECF0;
    --shadow: rgba(46, 125, 50, 0.08);
    --shadow-hover: rgba(46, 125, 50, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    background: var(--white);
    color: var(--text);
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */

.chat-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    background: var(--white);
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
}

/* ========================================
   HEADER
   ======================================== */

.chat-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.header-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.header-avatar svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.header-info {
    flex-grow: 1;
}

.header-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: 2px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #A5D6A7;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

#reset-chat-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

#reset-chat-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: rotate(180deg);
}

/* ========================================
   VENTANA DE CHAT
   ======================================== */

#chat-window {
    flex-grow: 1;
    padding: 20px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-chat);
    scroll-behavior: smooth;
}

#chat-window::-webkit-scrollbar {
    width: 6px;
}

#chat-window::-webkit-scrollbar-track {
    background: transparent;
}

#chat-window::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ========================================
   MENSAJES
   ======================================== */

.message {
    display: flex;
    gap: 10px;
    max-width: 90%;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-bot {
    align-self: flex-start;
}

.bot-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bot-avatar svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.55;
    font-size: 0.95rem;
}

.message-user .message-bubble {
    background: var(--user-bubble);
    color: white;
    border-bottom-right-radius: 6px;
}

.message-bot .message-bubble {
    background: var(--bot-bubble);
    color: var(--text);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.message-bubble h3 {
    font-size: 1rem;
    margin: 16px 0 8px 0;
    color: var(--primary-dark);
}

.message-bubble h3:first-child {
    margin-top: 0;
}

.message-bubble ul {
    margin: 8px 0;
    padding-left: 0;
    list-style: none;
}

.message-bubble ul li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 4px;
}

.message-bubble ul li::before {
    content: "•";
    position: absolute;
    left: 4px;
    color: var(--primary);
    font-weight: bold;
}

.message-bubble a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 500;
}

.message-bubble a:hover {
    text-decoration: underline;
}

.message-bubble strong {
    color: var(--primary-dark);
}

/* ========================================
   TARJETAS DE PRODUCTOS
   ======================================== */

.product-card {
    background: #FAFBFC;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin: 10px 0;
    transition: all 0.2s ease;
}

.product-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px var(--shadow);
}

.product-card-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.product-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.product-icon svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.product-info {
    flex-grow: 1;
}

.product-name {
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px 0;
    font-size: 0.95rem;
}

.product-detail {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.4;
}

.product-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    padding: 8px 14px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.product-link:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.product-link svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.product-hidden {
    display: none;
}

.show-more-products {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.08), rgba(0, 137, 123, 0.08));
    border: 1px dashed var(--primary);
    border-radius: 10px;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.show-more-products:hover {
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.15), rgba(0, 137, 123, 0.15));
}

.show-more-products svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.show-more-products:hover svg {
    transform: translateY(2px);
}

/* ========================================
   INDICADOR DE ESCRITURA
   ======================================== */

.typing-indicator {
    display: flex;
    gap: 10px;
    align-self: flex-start;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    background: var(--bot-bubble);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ========================================
   SUGERENCIAS RAPIDAS
   ======================================== */

.suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 16px;
    background: var(--bg-chat);
}

.suggestion-chip {
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.suggestion-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(46, 125, 50, 0.05);
}

.suggestion-chip svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* ========================================
    FORMULARIO DE ENTRADA
    ======================================== */

#chat-form {
    display: flex;
    padding: 16px;
    gap: 10px;
    background: var(--white);
    border-top: 1px solid var(--border);
    align-items: center;
}

#message-input {
    flex-grow: 1;
    border: 2px solid var(--border);
    padding: 12px 16px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--bg-chat);
}

#message-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

#message-input::placeholder {
    color: var(--text-muted);
}

#chat-form button {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#chat-form button svg {
    width: 22px;
    height: 22px;
    fill: white;
}

#chat-form button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

#chat-form button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

#upload-image-btn {
    background: linear-gradient(135deg, var(--accent), var(--primary-light));
    margin-right: 4px;
}

#upload-image-btn:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
}

/* ========================================
    PREVIEW DE IMAGEN
    ======================================== */

#image-preview-container {
    padding: 0 16px 8px;
    background: var(--white);
    border-top: 1px solid var(--border);
}

#image-preview-container:not(.d-none) {
    display: block;
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
    max-width: 200px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border);
    background: var(--bg-chat);
}

.image-preview-img {
    display: block;
    max-width: 100%;
    max-height: 150px;
    width: auto;
    height: auto;
    object-fit: cover;
}

.remove-image-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}

.remove-image-btn:hover {
    background: #fff;
    transform: scale(1.1);
}

.remove-image-btn svg {
    width: 16px;
    height: 16px;
    fill: #d32f2f;
}

/* Mensaje de bienvenida especial */
.welcome-message .message-bubble {
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.08), rgba(0, 137, 123, 0.08));
    border: 1px solid rgba(46, 125, 50, 0.15);
}

/* ========================================
   PRODUCTOS VETERINARIOS
   ======================================== */

.product-veterinary {
    border: 2px solid #E65100;
    background: linear-gradient(to bottom, #FFF8E1, #FAFBFC);
    position: relative;
}

.product-veterinary .product-icon {
    background: linear-gradient(135deg, #FF9800, #E65100);
}

.veterinary-banner {
    background: linear-gradient(135deg, #E65100, #F57C00);
    color: white;
    padding: 10px 12px;
    border-radius: 10px 10px 0 0;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    margin: -12px -12px 12px -12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.veterinary-banner svg {
    flex-shrink: 0;
}

.product-veterinary .product-name {
    color: #E65100;
}

.product-veterinary .product-detail {
    color: #BF360C;
}

.product-veterinary .product-link {
    background: linear-gradient(135deg, #FF9800, #E65100);
}

.product-veterinary .product-link:hover {
    background: linear-gradient(135deg, #E65100, #BF360C);
}

/* Utilidades */
.d-none { display: none !important; }

/* ========================================
   MODO VETERINARIO - Verde Oscuro
   ======================================== */

body.vet-mode {
    --primary: #1B5E20;
    --primary-light: #2E7D32;
    --primary-dark: #0D3B12;
    --accent: #388E3C;
    --shadow: rgba(27, 94, 32, 0.12);
}

body.vet-mode .chat-header {
    background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 100%);
}

body.vet-mode .bot-avatar {
    background: linear-gradient(135deg, #2E7D32, #1B5E20);
}

body.vet-mode .message-user .message-bubble {
    background: #1B5E20;
}

body.vet-mode .product-link {
    background: linear-gradient(135deg, #1B5E20, #2E7D32);
}

body.vet-mode .product-link:hover {
    background: linear-gradient(135deg, #0D3B12, #1B5E20);
}

body.vet-mode .status-dot {
    background: #81C784;
}

body.vet-mode .suggestion-chip:hover {
    border-color: #1B5E20;
    color: #1B5E20;
    background: rgba(27, 94, 32, 0.05);
}

body.vet-mode #chat-form button {
    background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 100%);
}

body.vet-mode .show-more-products {
    border-color: #1B5E20;
    color: #1B5E20;
    background: linear-gradient(135deg, rgba(27, 94, 32, 0.08), rgba(46, 125, 50, 0.08));
}

body.vet-mode .welcome-message .message-bubble {
    background: linear-gradient(135deg, rgba(27, 94, 32, 0.1), rgba(46, 125, 50, 0.08));
    border-color: rgba(27, 94, 32, 0.2);
}