/* ========================================
   PsicopeBot Chat Widget Styles
   ======================================== */

/* Variables */
:root {
    --psicopebot-primary: #2B6CB0;
    --psicopebot-primary-dark: #1e5a8e;
    --psicopebot-bg: #ffffff;
    --psicopebot-text: #1a202c;
    --psicopebot-text-light: #4a5568;
    --psicopebot-border: #e2e8f0;
    --psicopebot-shadow: rgba(0, 0, 0, 0.1);
    --psicopebot-shadow-lg: rgba(0, 0, 0, 0.15);
}

/* Widget Container */
.psicopebot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Toggle Button */
.psicopebot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--psicopebot-primary);
    border: none;
    box-shadow: 0 4px 12px var(--psicopebot-shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.psicopebot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px var(--psicopebot-shadow-lg);
}

.psicopebot-toggle svg {
    width: 28px;
    height: 28px;
    color: white;
}

.psicopebot-icon-close {
    display: none;
}

.psicopebot-widget.open .psicopebot-icon-open {
    display: none;
}

.psicopebot-widget.open .psicopebot-icon-close {
    display: block;
}

/* Pulse Animation */
.psicopebot-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: var(--psicopebot-primary);
    animation: psicopebot-pulse 2s infinite;
}

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

/* Chat Container */
.psicopebot-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--psicopebot-bg);
    border-radius: 16px;
    box-shadow: 0 8px 24px var(--psicopebot-shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: psicopebot-slide-up 0.3s ease;
}

.psicopebot-widget.open .psicopebot-container {
    display: flex;
}

@keyframes psicopebot-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.psicopebot-header {
    padding: 20px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.psicopebot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.psicopebot-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;
}

.psicopebot-avatar svg {
    width: 24px;
    height: 24px;
    color: white;
}

.psicopebot-header-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.psicopebot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.psicopebot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.95;
}

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

@keyframes status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.psicopebot-header-actions button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.psicopebot-header-actions button:hover {
    opacity: 0.8;
}

.psicopebot-header-actions svg {
    width: 20px;
    height: 20px;
}

/* Messages Area */
.psicopebot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f7fafc;
    scroll-behavior: smooth;
}

.psicopebot-messages::-webkit-scrollbar {
    width: 6px;
}

.psicopebot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.psicopebot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.psicopebot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message Styles */
.psicopebot-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: psicopebot-message-in 0.3s ease;
}

@keyframes psicopebot-message-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

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

.user-message .message-avatar {
    background: #e2e8f0;
}

.user-message .message-avatar svg {
    color: #4a5568;
}

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-content p {
    margin: 0;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.bot-message .message-content p {
    background: white;
    color: var(--psicopebot-text);
    border-top-left-radius: 4px;
    box-shadow: 0 1px 2px var(--psicopebot-shadow);
}

.user-message .message-content {
    align-items: flex-end;
}

.user-message .message-content p {
    background: var(--psicopebot-primary);
    color: white;
    border-top-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #a0aec0;
    padding: 0 4px;
}

/* Quick Questions */
.psicopebot-quick-questions {
    margin: 20px 0;
    animation: psicopebot-fade-in 0.5s ease;
}

@keyframes psicopebot-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.quick-questions-title {
    font-size: 13px;
    color: var(--psicopebot-text-light);
    margin-bottom: 12px;
    font-weight: 600;
}

.quick-questions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.quick-question-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: white;
    border: 1px solid var(--psicopebot-border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--psicopebot-text);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.quick-question-btn:hover {
    border-color: var(--psicopebot-primary);
    background: #f0f7ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px var(--psicopebot-shadow);
}

.quick-question-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--psicopebot-primary);
}

/* Typing Indicator */
.psicopebot-typing {
    padding: 0 20px 10px;
    background: #f7fafc;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    width: fit-content;
    box-shadow: 0 1px 2px var(--psicopebot-shadow);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

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

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

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Input Area */
.psicopebot-input-area {
    background: white;
    border-top: 1px solid var(--psicopebot-border);
    padding: 16px;
    flex-shrink: 0;
}

.psicopebot-form {
    margin-bottom: 8px;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.psicopebot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--psicopebot-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.psicopebot-input:focus {
    border-color: var(--psicopebot-primary);
}

.psicopebot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--psicopebot-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.psicopebot-send:hover {
    background: var(--psicopebot-primary-dark);
    transform: scale(1.05);
}

.psicopebot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.psicopebot-footer {
    text-align: center;
}

.psicopebot-footer span {
    font-size: 11px;
    color: #a0aec0;
}

/* WhatsApp Button */
.whatsapp-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #25d366;
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    margin-top: 12px;
    transition: all 0.2s;
}

.whatsapp-button:hover {
    background: #20ba5a;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.4);
}

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

/* Critical Modal */
.psicopebot-critical-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: psicopebot-fade-in 0.3s ease;
}

.critical-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 8px 24px var(--psicopebot-shadow-lg);
    animation: psicopebot-modal-slide 0.3s ease;
}

@keyframes psicopebot-modal-slide {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.critical-modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--psicopebot-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.critical-icon {
    font-size: 32px;
}

.critical-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--psicopebot-text);
}

.critical-modal-body {
    padding: 20px;
}

.critical-modal-body p {
    margin: 0 0 20px 0;
    color: var(--psicopebot-text-light);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--psicopebot-text);
}

.required {
    color: #f56565;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--psicopebot-border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--psicopebot-primary);
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-cancel,
.btn-submit {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel {
    background: #e2e8f0;
    color: var(--psicopebot-text);
}

.btn-cancel:hover {
    background: #cbd5e0;
}

.btn-submit {
    background: var(--psicopebot-primary);
    color: white;
}

.btn-submit:hover {
    background: var(--psicopebot-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--psicopebot-shadow);
}

/* Responsive */
@media (max-width: 480px) {
    .psicopebot-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .psicopebot-container {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -10px;
    }
    
    .quick-questions-grid {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .psicopebot-widget {
        display: none !important;
    }
}