/**
 * Chatbot Styles - WhatsApp-like interface
 * Reserver Restaurant Booking System
 *
 * --chatbot-primary / --chatbot-secondary: solo se usan en el header y fondo de página.
 * El resto de la UI usa colores fijos estándar para garantizar legibilidad.
 */

/* CSS Variables */
:root {
    --chatbot-primary: #667eea;
    --chatbot-secondary: #764ba2;
    --chatbot-bg: #f0f2f5;
    --chatbot-accent: #3b82f6;
    --chatbot-accent-dark: #2563eb;
    --chatbot-message-user: #3b82f6;
    --chatbot-message-assistant: #ffffff;
    --chatbot-text-dark: #1f2937;
    --chatbot-text-light: #6b7280;
    --chatbot-border: #e5e7eb;
    --chatbot-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --chatbot-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Page container - usa colores del restaurante */
.chatbot-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Chat wrapper */
.chat-wrapper {
    width: 100%;
    max-width: 480px;
    height: calc(100vh - 40px);
    max-height: 800px;
    background: #fff;
    border-radius: 24px;
    box-shadow: var(--chatbot-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header - usa colores del restaurante */
.chat-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-logo-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chat-header-text h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.chat-status {
    font-size: 0.8rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-dot.offline {
    background: #9ca3af;
    animation: none;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.btn-header {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--chatbot-bg);
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Messages */
.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.message.user .message-content {
    background: var(--chatbot-message-user);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant .message-content {
    background: var(--chatbot-message-assistant);
    color: var(--chatbot-text-dark);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.message.error .message-content {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.message-time {
    font-size: 0.7rem;
    color: var(--chatbot-text-light);
    margin-top: 4px;
    padding: 0 8px;
}

.message.user .message-time {
    text-align: right;
}

/* Typing indicator */
.typing-indicator {
    display: none;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    width: fit-content;
    margin: 0 16px 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    align-self: flex-start;
}

.typing-indicator.active {
    display: flex;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--chatbot-accent);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input area */
.chat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid var(--chatbot-border);
    flex-shrink: 0;
}

.chat-unavailable-notice {
    text-align: center;
    padding: 8px 0;
}

.chat-unavailable-notice .btn-reservations {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--chatbot-accent);
    color: white;
    text-decoration: none;
    border-radius: 24px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-unavailable-notice .btn-reservations:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    color: white;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--chatbot-bg);
    border-radius: 24px;
    padding: 8px 12px;
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 0.95rem;
    line-height: 1.4;
    max-height: 100px;
    outline: none;
    font-family: inherit;
    padding: 4px 0;
    color: var(--chatbot-text-dark);
}

#chat-input::placeholder {
    color: var(--chatbot-text-light);
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--chatbot-accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-send:active:not(:disabled) {
    transform: scale(0.95);
}

/* Suggestions */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    transition: opacity 0.3s, max-height 0.3s;
    overflow: hidden;
}

.chat-suggestions.hidden {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
}

.suggestion-btn {
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: white;
    color: #374151;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.suggestion-btn:hover {
    background: var(--chatbot-accent);
    border-color: var(--chatbot-accent);
    color: white;
}

.suggestion-btn i {
    font-size: 0.9em;
}

/* Footer */
.chat-footer {
    padding: 8px 16px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--chatbot-text-light);
    background: white;
    border-top: 1px solid var(--chatbot-border);
    flex-shrink: 0;
}

.chat-footer a {
    color: var(--chatbot-accent);
    text-decoration: none;
}

.chat-footer a:hover {
    text-decoration: underline;
}

.recaptcha-branding {
    margin-top: 4px;
    font-size: 0.65rem;
    color: #9ca3af;
}

.recaptcha-branding a {
    color: #9ca3af;
}

/* Booking confirmation */
.booking-confirmation {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 16px;
    padding: 16px 20px;
    margin: 8px 0;
    animation: messageIn 0.3s ease;
}

.confirmation-icon {
    font-size: 2rem;
    color: #10b981;
}

.confirmation-text {
    color: #065f46;
    font-size: 0.95rem;
}

.confirmation-text strong {
    display: block;
    font-size: 1.1rem;
    margin-top: 4px;
}

/* QR Code in confirmation */
.confirmation-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.confirmation-qr .qr-image {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    border: 2px solid #a7f3d0;
    background: white;
}

.confirmation-qr .qr-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #10b981;
    color: white;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s ease;
}

.confirmation-qr .qr-download-btn:hover {
    background: #059669;
}

/* Responsive QR for mobile */
@media (max-width: 480px) {
    .booking-confirmation {
        flex-direction: column;
        text-align: center;
    }

    .confirmation-qr {
        margin-left: 0;
        margin-top: 10px;
    }

    .confirmation-qr .qr-image {
        width: 150px;
        height: 150px;
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 32px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
}

.modal-icon.success {
    background: #ecfdf5;
    color: #10b981;
}

.modal-icon.info {
    background: var(--chatbot-accent);
    color: white;
}

.modal-content h3 {
    margin: 0 0 8px;
    font-size: 1.25rem;
    color: var(--chatbot-text-dark);
}

.modal-content p {
    margin: 0 0 24px;
    color: var(--chatbot-text-light);
    font-size: 0.95rem;
}

.btn-modal-close {
    padding: 12px 32px;
    border: none;
    border-radius: 12px;
    background: var(--chatbot-accent);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.btn-modal-close:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Terms modal */
.terms-modal-content {
    max-width: 420px;
    text-align: left;
}

.terms-modal-content h3 {
    text-align: center;
}

.terms-modal-content .modal-icon {
    margin-bottom: 20px;
}

.terms-text {
    font-size: 0.9rem;
    color: var(--chatbot-text-dark);
    line-height: 1.6;
    margin-bottom: 20px;
}

.terms-text p {
    margin: 0 0 12px;
    color: inherit;
}

.terms-text ul {
    margin: 0 0 16px;
    padding-left: 24px;
}

.terms-text li {
    margin-bottom: 8px;
    color: var(--chatbot-text-light);
}

.terms-text .privacy-link {
    margin: 16px 0 0;
    text-align: center;
}

.terms-text .privacy-link a {
    color: var(--chatbot-accent);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.terms-text .privacy-link a:hover {
    text-decoration: underline;
}

.terms-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-terms-accept,
.btn-terms-decline {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.btn-terms-accept {
    background: var(--chatbot-accent);
    color: white;
}

.btn-terms-accept:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-terms-decline {
    background: transparent;
    color: var(--chatbot-text-light);
    border: 1px solid var(--chatbot-border);
}

.btn-terms-decline:hover {
    background: var(--chatbot-bg);
}

/* Responsive */
@media (max-width: 520px) {
    .chatbot-page {
        padding: 0;
    }

    .chat-wrapper {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .chat-header {
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .chat-logo,
    .chat-logo-placeholder {
        width: 42px;
        height: 42px;
    }

    .chat-header-text h1 {
        font-size: 1rem;
    }

    .message {
        max-width: 90%;
    }

    .chat-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .chat-suggestions {
        gap: 6px;
    }

    .suggestion-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chat-wrapper {
        background: #1f2937;
    }

    .message.assistant .message-content {
        background: #374151;
        color: #f3f4f6;
    }

    .chat-input-area,
    .chat-footer {
        background: #1f2937;
        border-color: #374151;
    }

    .chat-input-wrapper {
        background: #374151;
    }

    #chat-input {
        color: #f3f4f6;
    }

    .message-content a {
        color: #f3f4f6;
    }

    .suggestion-btn {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }

    .suggestion-btn:hover {
        background: var(--chatbot-accent);
        border-color: var(--chatbot-accent);
        color: #fff;
    }

    .modal-content {
        background: #1f2937;
    }

    .modal-content h3 {
        color: #f3f4f6;
    }

    .modal-content p {
        color: #9ca3af;
    }

    .terms-text {
        color: #f3f4f6;
    }

    .terms-text li {
        color: #9ca3af;
    }

    .btn-terms-decline {
        border-color: #4b5563;
        color: #9ca3af;
    }

    .btn-terms-decline:hover {
        background: #374151;
    }
}

/* Print styles */
@media print {
    .chat-input-area,
    .chat-footer,
    .chat-header-actions,
    .chat-suggestions {
        display: none !important;
    }

    .chatbot-page {
        background: white;
        padding: 0;
    }

    .chat-wrapper {
        box-shadow: none;
        border-radius: 0;
        max-height: none;
        height: auto;
    }

    .chat-messages {
        overflow: visible;
    }
}

/* Hide reCAPTCHA badge - attribution text is shown in footer as required by Google */
.grecaptcha-badge {
    visibility: hidden !important;
}
