/* AeroIA Chat - Estilos Públicos */

.aeroia-chat-widget {
    font-family: var(--aeroia-font-family);
    font-size: var(--aeroia-font-size);
    color: var(--aeroia-font-color);
    z-index: 999999;
}

/* Widget flotante */
.aeroia-chat-widget.floating {
    position: fixed;
}

.aeroia-chat-widget.position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.aeroia-chat-widget.position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.aeroia-chat-widget.position-top-right {
    top: 20px;
    right: 20px;
}

.aeroia-chat-widget.position-top-left {
    top: 20px;
    left: 20px;
}

/* Widget inline */
.aeroia-chat-widget.inline {
    position: relative;
    max-width: 100%;
    margin: 20px 0;
}

/* Botón toggle flotante */
.aeroia-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aeroia-button-color);
    color: var(--aeroia-button-text-color);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.aeroia-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.aeroia-chat-toggle:active {
    transform: scale(0.95);
}

.aeroia-chat-toggle.active {
    transform: rotate(90deg);
}

.aeroia-chat-toggle svg {
    width: 28px;
    height: 28px;
    transition: all 0.3s ease;
}

/* Contenedor del chat */
.aeroia-chat-container {
    width: var(--aeroia-chat-width);
    height: var(--aeroia-chat-height);
    max-width: 100%;
    max-height: 90vh;
    background: var(--aeroia-background-color);
    border-radius: var(--aeroia-border-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.aeroia-chat-widget.inline .aeroia-chat-container {
    width: 100%;
    max-width: var(--aeroia-chat-width);
    margin: 0 auto;
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Header */
.aeroia-chat-header {
    background: var(--aeroia-theme-color);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--aeroia-border-radius) var(--aeroia-border-radius) 0 0;
}

.aeroia-chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

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

.aeroia-chat-avatar svg {
    width: 24px;
    height: 24px;
}

.aeroia-chat-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.aeroia-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.aeroia-chat-actions {
    display: flex;
    gap: 8px;
}

.aeroia-chat-minimize {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.aeroia-chat-minimize:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages area */
.aeroia-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9f9f9;
    scroll-behavior: smooth;
}

.aeroia-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: slideIn 0.3s ease-out;
}

.aeroia-message.user-message {
    flex-direction: row-reverse;
}

.aeroia-message .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aeroia-message.bot-message .message-avatar {
    background: var(--aeroia-theme-color);
    color: white;
}

.aeroia-message.user-message .message-avatar {
    background: var(--aeroia-user-message-bg);
    color: white;
}

.aeroia-message.error-message .message-avatar {
    background: #f44336;
    color: white;
}

.aeroia-message .message-avatar svg {
    width: 18px;
    height: 18px;
}

.aeroia-message .message-content {
    flex: 1;
    max-width: 75%;
}

.aeroia-message.user-message .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: var(--aeroia-border-radius);
    word-wrap: break-word;
    line-height: 1.5;
}

.bot-message .message-bubble {
    background: var(--aeroia-bot-message-bg);
    color: var(--aeroia-bot-message-color);
    border-bottom-left-radius: 4px;
}

.user-message .message-bubble {
    background: var(--aeroia-user-message-bg);
    color: var(--aeroia-user-message-color);
    border-bottom-right-radius: 4px;
}

.error-message .message-bubble {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef5350;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* Typing indicator */
.aeroia-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--aeroia-theme-color);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

/* Input area */
.aeroia-chat-input {
    background: white;
    border-top: 1px solid #e0e0e0;
}

.aeroia-chat-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    align-items: flex-end;
}

.aeroia-message-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: calc(var(--aeroia-border-radius) / 2);
    padding: 10px 12px;
    font-family: inherit;
    font-size: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    max-height: 120px;
    overflow-y: auto;
}

.aeroia-message-input:focus {
    border-color: var(--aeroia-theme-color);
}

.aeroia-message-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.aeroia-send-button {
    background: var(--aeroia-button-color);
    color: var(--aeroia-button-text-color);
    border: none;
    border-radius: calc(var(--aeroia-border-radius) / 2);
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    transition: all 0.2s;
    flex-shrink: 0;
}

.aeroia-send-button:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.aeroia-send-button:active:not(:disabled) {
    transform: translateY(0);
}

.aeroia-send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.aeroia-send-button.sending svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.aeroia-send-button svg {
    width: 20px;
    height: 20px;
}

.aeroia-chat-footer {
    text-align: center;
    padding: 8px 12px;
    font-size: 11px;
    color: #999;
    background: #f9f9f9;
}

/* Debug panel */
.aeroia-debug-panel {
    border-top: 2px solid var(--aeroia-theme-color);
    background: #1e1e1e;
    color: #d4d4d4;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #2d2d2d;
    cursor: pointer;
}

.debug-header h4 {
    margin: 0;
    font-size: 12px;
    color: #4ec9b0;
}

.debug-toggle {
    background: none;
    border: none;
    color: #d4d4d4;
    cursor: pointer;
    padding: 4px;
    display: flex;
}

.debug-toggle svg {
    transition: transform 0.3s;
}

.debug-toggle svg.rotated {
    transform: rotate(180deg);
}

.debug-content {
    max-height: 150px;
    overflow-y: auto;
}

.debug-output {
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.4;
}

.debug-entry {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #3c3c3c;
}

.debug-entry:last-child {
    border-bottom: none;
}

.debug-entry.error {
    color: #f48771;
}

.debug-timestamp {
    color: #4ec9b0;
    font-weight: bold;
    margin-bottom: 4px;
}

.debug-data {
    color: #ce9178;
}

/* Scrollbar styling */
.aeroia-chat-messages::-webkit-scrollbar,
.aeroia-message-input::-webkit-scrollbar,
.debug-content::-webkit-scrollbar {
    width: 6px;
}

.aeroia-chat-messages::-webkit-scrollbar-track,
.aeroia-message-input::-webkit-scrollbar-track,
.debug-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.aeroia-chat-messages::-webkit-scrollbar-thumb,
.aeroia-message-input::-webkit-scrollbar-thumb,
.debug-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.aeroia-chat-messages::-webkit-scrollbar-thumb:hover,
.aeroia-message-input::-webkit-scrollbar-thumb:hover,
.debug-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Error state */
.aeroia-chat-error {
    padding: 20px;
    background: #ffebee;
    border: 1px solid #ef5350;
    border-radius: 8px;
    color: #c62828;
    text-align: center;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .aeroia-chat-widget.floating .aeroia-chat-container {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        max-width: none;
        max-height: none;
    }

    .aeroia-chat-widget.position-bottom-right,
    .aeroia-chat-widget.position-bottom-left {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .aeroia-chat-toggle {
        width: 56px;
        height: 56px;
    }

    .aeroia-message .message-content {
        max-width: 85%;
    }
}

/* Accessibility */
.aeroia-chat-widget button:focus-visible,
.aeroia-message-input:focus-visible {
    outline: 2px solid var(--aeroia-theme-color);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .aeroia-chat-widget *,
    .aeroia-chat-widget *::before,
    .aeroia-chat-widget *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
