/**
 * =====================================================
 * PRESCRIPTO CHATBOT WIDGET STYLING
 * =====================================================
 */

:root {
    --chatbot-primary: #667eea;
    --chatbot-secondary: #764ba2;
    --chatbot-success: #10b981;
    --chatbot-text: #1f2937;
    --chatbot-text-light: #6b7280;
    --chatbot-bg-light: #f9fafb;
    --chatbot-border: #e5e7eb;
    --chatbot-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ===== CONTAINER ===== */
#chatbot-container {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

#chatbot-container.chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

#chatbot-container.chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* ===== TOGGLE BUTTON ===== */
.chatbot-toggle-btn {
    position: relative;
    width: 100px;
    height: 100px;
    min-width: 100px;
    min-height: 100px;
    max-width: 100px;
    max-height: 100px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--chatbot-shadow);
    transition: all 0.3s ease;
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
}

.chatbot-toggle-btn img {
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 50%;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    object-fit: cover;
    aspect-ratio: 1 / 1;
    clip-path: circle(50%);
    -webkit-clip-path: circle(50%);
    display: block;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 20px 25px -5px rgba(102, 126, 234, 0.4);
}

.chatbot-toggle-btn:active {
    transform: scale(0.95);
}

.chatbot-toggle-btn svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

.chatbot-toggle-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

.chatbot-toggle-btn.active .badge {
    display: none;
}

/* ===== CHAT WINDOW ===== */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
}

.chatbot-window.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* ===== HEADER ===== */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-header .header-content h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-header .status {
    margin: 4px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chatbot-header .status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

.close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.close-btn:hover {
    transform: rotate(90deg);
}

/* ===== MESSAGES CONTAINER ===== */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: var(--chatbot-bg-light);
}

/* Scrollbar styling */
#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-text-light);
}

/* ===== MESSAGES ===== */
.chatbot-message {
    display: flex;
    animation: slideIn 0.3s ease;
}

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

.chatbot-message-user {
    justify-content: flex-end;
}

.chatbot-message-bot {
    justify-content: flex-start;
}

.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chatbot-message-user .message-content {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message-bot .message-content {
    background: white;
    color: var(--chatbot-text);
    border: 1px solid var(--chatbot-border);
    border-bottom-left-radius: 4px;
}

/* ===== CHATBOT LINKS ===== */
.chatbot-link {
    color: var(--chatbot-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    word-break: break-word;
}

.chatbot-link:hover {
    color: var(--chatbot-secondary);
    text-decoration: underline;
}

.chatbot-message-user .chatbot-link {
    color: #fff;
    text-decoration: underline;
}

.chatbot-message-user .chatbot-link:hover {
    color: #e0e0e0;
}

/* Link icon (optional) */
.chatbot-link::after {
    content: ' ↗';
    font-size: 0.8em;
    opacity: 0.7;
}

/* ===== MESSAGE WRAPPER ===== */
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

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

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

.message-wrapper .message-content {
    max-width: 100%;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--chatbot-text-light);
    animation: bounce 1.4s infinite;
}

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

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

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

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

/* ===== FEEDBACK ===== */
.message-feedback {
    margin-top: 6px;
    padding: 6px 0;
    text-align: left;
}

.message-feedback small {
    display: block;
    color: var(--chatbot-text-light);
    font-size: 11px;
    margin-bottom: 4px;
}

.feedback-buttons {
    display: flex;
    gap: 6px;
    justify-content: flex-start;
}

.feedback-btn {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--chatbot-border);
    background: white;
    color: var(--chatbot-text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.feedback-btn:hover {
    background: var(--chatbot-bg-light);
}

.feedback-btn.active {
    background: var(--chatbot-primary);
    color: white;
    border-color: var(--chatbot-primary);
}

/* ===== INPUT AREA ===== */
.chatbot-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: white;
    border-top: 1px solid var(--chatbot-border);
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--chatbot-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#chatbot-input:focus {
    outline: none;
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: none;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

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

.send-btn svg {
    width: 18px;
    height: 18px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    #chatbot-container.chatbot-bottom-right,
    #chatbot-container.chatbot-bottom-left {
        bottom: 10px;
        right: 10px;
        left: auto;
    }

    .chatbot-toggle-btn {
        width: 80px !important;
        height: 80px !important;
        min-width: 80px !important;
        min-height: 80px !important;
        max-width: 80px !important;
        max-height: 80px !important;
        border-radius: 50% !important;
        -webkit-border-radius: 50% !important;
        -moz-border-radius: 50% !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    .chatbot-toggle-btn img {
        width: 100% !important;
        height: 100% !important;
        min-width: 100% !important;
        min-height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 50% !important;
        -webkit-border-radius: 50% !important;
        -moz-border-radius: 50% !important;
        object-fit: cover !important;
        display: block !important;
        clip-path: circle(50%) !important;
        -webkit-clip-path: circle(50%) !important;
    }

    .chatbot-toggle-btn .badge {
        top: -3px !important;
        right: -3px !important;
        width: 20px !important;
        height: 20px !important;
        font-size: 10px !important;
    }

    .chatbot-window {
        width: calc(100vw - 20px);
        height: 70vh;
        max-height: 500px;
        border-radius: 12px;
    }

    .message-content {
        max-width: 90%;
    }
}

/* ===== DARK THEME ===== */
.chatbot-dark #chatbot-messages {
    background-color: #1f2937;
}

.chatbot-dark .message-content {
    background: #374151;
    color: #f9fafb;
    border-color: #4b5563;
}

.chatbot-dark #chatbot-input {
    background-color: #374151;
    color: #f9fafb;
    border-color: #4b5563;
}

.chatbot-dark #chatbot-input::placeholder {
    color: #9ca3af;
}

.chatbot-dark .feedback-btn {
    background: #374151;
    color: #f9fafb;
    border-color: #4b5563;
}

.chatbot-dark .feedback-btn:hover {
    background: #4b5563;
}
