/* ============================================================
   SCOMET.in — Chatbot Styles (chatbot.css)
   Chatbot panel, chat bubbles, modals, OTP input, feedback
   ============================================================ */

/* --- CHATBOT PANEL --- */
.chatbot-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-height: calc(100vh - 120px);
    min-height: 500px;
}

/* --- CHATBOT HEADER --- */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--color-primary);
    color: var(--color-white);
    flex-shrink: 0;
}

.chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chatbot-avatar {
    font-size: 1.5rem;
}

.chatbot-title {
    font-size: var(--font-size-base);
    font-weight: 600;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted);
}
.status-dot.online {
    background: var(--color-success);
    box-shadow: 0 0 4px var(--color-success);
}

.status-text {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.7);
}

.chatbot-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--color-white);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: var(--transition);
}
.header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.user-greeting {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* --- CHAT AREA --- */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #FAFBFC;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.chat-area::-webkit-scrollbar {
    width: 6px;
}
.chat-area::-webkit-scrollbar-track {
    background: transparent;
}
.chat-area::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

/* --- CHAT BUBBLES --- */
.chat-message {
    display: flex;
    gap: 0.5rem;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

/* User message — right aligned */
.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.user .bubble {
    background: var(--color-primary);
    color: var(--color-white);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}

/* Assistant message — left aligned */
.chat-message.assistant {
    align-self: flex-start;
}

.chat-message.assistant .bubble {
    background: var(--color-white);
    color: var(--color-text);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

/* System message */
.chat-message.system {
    align-self: center;
    max-width: 90%;
}
.chat-message.system .bubble {
    background: #FFF7ED;
    color: var(--color-text);
    border: 1px solid #FDE8D0;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    text-align: center;
}

.bubble {
    padding: 0.75rem 1rem;
    font-size: var(--font-size-sm);
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Markdown content inside bubbles */
.bubble h3 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}
.bubble h3:first-child {
    margin-top: 0;
}
.bubble ul, .bubble ol {
    padding-left: 1.25rem;
    margin: 0.25rem 0;
}
.bubble li {
    margin-bottom: 0.125rem;
}
.bubble strong {
    font-weight: 600;
}
.bubble code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.8em;
}

.chat-message.user .bubble code {
    background: rgba(255, 255, 255, 0.15);
}

/* --- SCOMET Code Badge --- */
.scomet-code {
    display: inline-block;
    background: var(--color-accent);
    color: var(--color-white);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    margin: 0 0.125rem;
}

/* --- Sources Section --- */
.message-sources {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border-light);
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.source-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    color: var(--color-text-secondary);
}

.source-tag .source-icon {
    font-size: 0.65rem;
}

/* --- Feedback Thumbs (per message) --- */
.message-feedback {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.375rem;
}

.feedback-thumb {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    opacity: 0.5;
    transition: var(--transition);
}
.feedback-thumb:hover {
    opacity: 1;
    background: var(--color-border-light);
}
.feedback-thumb.active {
    opacity: 1;
}

/* --- TYPING INDICATOR --- */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: #FAFBFC;
    flex-shrink: 0;
}

.chatbot-avatar-small {
    font-size: 1rem;
}

.typing-text {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots .dot {
    width: 5px;
    height: 5px;
    background: var(--color-text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dots .dot:nth-child(1) { animation-delay: 0s; }
.typing-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* --- UPLOAD AREA --- */
.upload-area {
    padding: 0.625rem 1.25rem;
    background: #F0F7FF;
    border-top: 1px solid #D0E3FF;
    flex-shrink: 0;
}

.upload-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.upload-icon {
    font-size: 1.125rem;
}

.upload-text {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.upload-input {
    font-size: var(--font-size-xs);
    max-width: 200px;
}

.upload-progress {
    margin-top: 0.5rem;
}

.progress-bar {
    height: 4px;
    background: var(--color-border-light);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* --- INPUT AREA --- */
.input-area {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-white);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 0.375rem 0.5rem 0.375rem 0.875rem;
    transition: var(--transition);
}
.input-wrapper:focus-within {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(232, 93, 44, 0.08);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    resize: none;
    outline: none;
    padding: 0.375rem 0;
    max-height: 120px;
    line-height: 1.5;
}
.chat-input::placeholder {
    color: var(--color-text-muted);
}

.btn-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--color-accent);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.btn-send:hover:not(:disabled) {
    background: var(--color-accent-hover);
}
.btn-send:disabled {
    background: var(--color-border);
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.375rem;
    padding: 0 0.25rem;
}

.char-count {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.guest-counter {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* --- MODAL OVERLAY --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(27, 42, 74, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    animation: fadeIn 0.2s ease;
}

.modal-container {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 90%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    position: relative;
}

.modal-small {
    max-width: 380px;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.25rem;
}

.modal-logo {
    text-align: center;
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.modal-title {
    text-align: center;
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.modal-subtitle {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.modal-footer-text {
    text-align: center;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: 1.5;
}

.modal-back {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    cursor: pointer;
    margin-bottom: 1rem;
    padding: 0;
}
.modal-back:hover {
    color: var(--color-text);
}

.modal-switch {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-top: 1rem;
}

.modal-screen {
    animation: fadeIn 0.2s ease;
}

/* --- OTP INPUT --- */
.otp-input-group {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.otp-digit {
    width: 48px;
    height: 56px;
    text-align: center;
    font-family: var(--font-family);
    font-size: var(--font-size-2xl);
    font-weight: 700;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-white);
    color: var(--color-primary);
    outline: none;
    transition: var(--transition);
}
.otp-digit:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(232, 93, 44, 0.15);
}

.otp-resend {
    text-align: center;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 0.75rem;
}
.otp-resend a.disabled {
    color: var(--color-text-muted);
    pointer-events: none;
    cursor: not-allowed;
}
.resend-timer {
    font-weight: 600;
    color: var(--color-accent);
}

/* --- STAR RATING --- */
.star-rating {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.star {
    font-size: 1.75rem;
    color: var(--color-border);
    cursor: pointer;
    transition: var(--transition);
}
.star:hover,
.star.active {
    color: var(--color-warning);
}

/* --- WELCOME MESSAGE --- */
.welcome-message {
    text-align: center;
    padding: 1rem;
}

.welcome-message h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.welcome-message p {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
}

.quick-questions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

.quick-question-btn {
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-family);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    cursor: pointer;
    text-align: left;
    transition: var(--transition);
}
.quick-question-btn:hover {
    background: var(--color-white);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* --- RESPONSIVE CHATBOT --- */
@media (max-width: 1024px) {
    .chatbot-panel {
        max-height: calc(100vh - 160px);
    }
}

@media (max-width: 768px) {
    .chatbot-panel {
        border-radius: var(--radius-md);
        max-height: calc(100vh - 140px);
        min-height: 400px;
    }
    .chat-message {
        max-width: 92%;
    }
    .otp-digit {
        width: 40px;
        height: 48px;
        font-size: var(--font-size-xl);
    }
    .modal-container {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .chatbot-panel {
        border-radius: 0;
        max-height: none;
        min-height: calc(100vh - 130px);
    }
    .chatbot-header-right .header-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.65rem;
    }
}
