/**
 * Symbot Widget Styles
 * Chatbot moderno con glassmorphism
 */

/* Botón flotante */
.symbot-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    color: white;
    overflow: hidden;
    touch-action: manipulation;
}

.symbot-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.symbot-button .symbot-fallback-text {
    font-size: 20px;
}

.symbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.6);
}

.symbot-button.active {
    transform: scale(0.9);
}

.symbot-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid white;
}

/* Mensaje de ayuda flotante */
.symbot-help-message {
    position: fixed;
    bottom: 32px;
    right: 100px;
    background: rgba(102, 126, 234, 0.85);
    color: white;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.3);
    z-index: 9997;
    white-space: nowrap;
    animation: helpMessageBounce 2s ease-in-out infinite;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.symbot-help-message::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid rgba(102, 126, 234, 0.85);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

@keyframes helpMessageBounce {
    0%, 100% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(-5px);
    }
}

/* Contenedor del chat */
.symbot-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 600px;
    background: rgba(15, 10, 31, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(167, 139, 250, 0.3);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 100px rgba(99, 102, 241, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.symbot-header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.12) 100%);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Safe area support para iOS (iPhone X+) */
@supports (padding-top: env(safe-area-inset-top)) {
    .symbot-header {
        padding-top: calc(20px + env(safe-area-inset-top));
    }
}

.symbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.symbot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.symbot-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.symbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.symbot-fallback-text {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
}

.symbot-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.symbot-title {
    font-weight: 700;
    font-size: 16px;
    color: #ffffff;
}

.symbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.symbot-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.symbot-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: rgba(255, 255, 255, 0.7);
}

.symbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.symbot-new-chat-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: rgba(255, 255, 255, 0.7);
}

.symbot-new-chat-btn:hover {
    background: rgba(167, 139, 250, 0.2);
    color: #a78bfa;
}

/* Messages Container */
.symbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.symbot-messages::-webkit-scrollbar {
    width: 6px;
}

.symbot-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.symbot-messages::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.3);
    border-radius: 10px;
}

.symbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(167, 139, 250, 0.5);
}

/* Message */
.symbot-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.symbot-message-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.symbot-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.symbot-message-avatar .symbot-fallback-text {
    font-size: 14px;
}

.symbot-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #ffffff;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.symbot-message-assistant .symbot-message-content {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.symbot-message-user {
    flex-direction: row-reverse;
}

.symbot-message-user .symbot-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 1px solid rgba(167, 139, 250, 0.5);
    text-align: left;
}

.symbot-message-content a {
    color: #a78bfa;
    text-decoration: underline;
}

.symbot-message-content a:hover {
    color: #c4b5fd;
}

/* Typing Indicator */
.symbot-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.symbot-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #a78bfa;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.symbot-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.symbot-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
.symbot-input-container {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: rgba(0, 0, 0, 0.2);
}

.symbot-voice-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    flex-shrink: 0;
    touch-action: manipulation;
}

.symbot-voice-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(167, 139, 250, 0.5);
}

.symbot-voice-btn.recording {
    background: #ef4444;
    border-color: #ef4444;
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

.symbot-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: #ffffff;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    resize: none;
    max-height: 120px;
    transition: all 0.2s;
    touch-action: manipulation;
}

.symbot-input:focus {
    outline: none;
    border-color: rgba(167, 139, 250, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.symbot-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.symbot-send-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    flex-shrink: 0;
    touch-action: manipulation;
}

.symbot-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.symbot-send-btn:active {
    transform: scale(0.95);
}

/* Recording Indicator */
.symbot-recording-indicator {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(239, 68, 68, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

.symbot-recording-animation {
    display: flex;
    align-items: center;
    justify-content: center;
}

.symbot-recording-dot {
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    animation: recordingDotPulse 1s infinite;
}

@keyframes recordingDotPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.symbot-recording-text {
    flex: 1;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

.symbot-stop-recording-btn {
    background: #ef4444;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.symbot-stop-recording-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.symbot-stop-recording-btn:active {
    transform: scale(0.95);
}

/* Footer */
.symbot-footer {
    padding: 12px 20px;
    text-align: center;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.symbot-footer strong {
    color: #a78bfa;
}

/* Formulario de usuario */
.symbot-user-form {
    display: flex;
    flex: 1;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    padding-top: 24px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    overflow-y: auto;
}

.symbot-form-content {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.symbot-form-header {
    text-align: center;
    margin-bottom: 28px;
}

.symbot-form-header h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.symbot-form-header p {
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.symbot-form-group {
    margin-bottom: 20px;
}

.symbot-form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.symbot-form-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 14px;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: all 0.3s;
    box-sizing: border-box;
}

.symbot-form-group input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.symbot-form-group input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

.symbot-form-submit {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.symbot-form-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.symbot-form-submit:active {
    transform: translateY(0);
}

.symbot-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Responsive */
@media (max-width: 768px) {
    .symbot-container {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height */
        border-radius: 0;
        max-height: 100vh;
        max-height: 100dvh;
        position: fixed;
    }

    /* Safe area support para iOS en mobile */
    @supports (padding-top: env(safe-area-inset-top)) {
        .symbot-container {
            height: calc(100vh - env(safe-area-inset-bottom));
            height: calc(100dvh - env(safe-area-inset-bottom));
            padding-bottom: env(safe-area-inset-bottom);
        }
    }

    .symbot-button {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .symbot-help-message {
        bottom: 28px;
        right: 86px;
        font-size: 13px;
        padding: 10px 16px;
    }

    /* Asegurar que el botón esté sobre el safe area en iOS */
    @supports (bottom: env(safe-area-inset-bottom)) {
        .symbot-button {
            bottom: calc(20px + env(safe-area-inset-bottom));
        }
        
        .symbot-help-message {
            bottom: calc(28px + env(safe-area-inset-bottom));
        }
    }
}

@media (max-width: 480px) {
    .symbot-button {
        bottom: 16px;
        right: 16px;
    }

    .symbot-message-content {
        max-width: 85%;
        font-size: 13px;
        padding: 10px 14px;
    }
}
