/**
 * Chat Widget Styles - Ordertune Design
 * Primary Color: Neon Green #c5ff00
 * Background: Dark/Black
 */

/* Variables - Ordertune Colors */
:root {
    --ordertune-neon-green: #c5ff00;
    --ordertune-dark-bg: #1a1a1a;
    --ordertune-darker-bg: #0d0d0d;
    --ordertune-text-light: #ffffff;
    --ordertune-text-gray: #a0a0a0;
    --ordertune-border: #333333;
    --ordertune-shadow: 0 8px 32px rgba(197, 255, 0, 0.15);
    --ordertune-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --ordertune-z-index: 999999;
}

/* Widget container */
.ordertune-chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--ordertune-z-index);
    font-family: var(--ordertune-font-family);
}

/* Chat button */
.ordertune-chat-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ordertune-neon-green);
    color: var(--ordertune-darker-bg);
    border: none;
    cursor: pointer;
    box-shadow: 0 3px 16px rgba(197, 255, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.ordertune-chat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 24px rgba(197, 255, 0, 0.5);
}

.ordertune-chat-button:active {
    transform: scale(0.95);
}

.ordertune-chat-icon,
.ordertune-close-icon {
    width: 22px;
    height: 22px;
    transition: all 0.3s ease;
}

.ordertune-chat-button .ordertune-close-icon {
    position: absolute;
    opacity: 0;
    transform: rotate(90deg);
}

.ordertune-chat-button.active .ordertune-chat-icon {
    opacity: 0;
    transform: rotate(-90deg);
}

.ordertune-chat-button.active .ordertune-close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Chat window */
.ordertune-chat-window {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--ordertune-dark-bg);
    border-radius: 20px;
    box-shadow: var(--ordertune-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: contain;
    isolation: isolate;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--ordertune-border);
}

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

/* Header */
.ordertune-chat-header {
    background: var(--ordertune-darker-bg);
    color: var(--ordertune-text-light);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--ordertune-border);
}

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

.ordertune-bot-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ordertune-neon-green);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ordertune-darker-bg);
    flex-shrink: 0;
}

.ordertune-bot-avatar svg {
    width: 24px;
    height: 24px;
}

.ordertune-bot-info {
    flex: 1;
}

.ordertune-bot-name {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.3;
    color: var(--ordertune-text-light);
}

.ordertune-bot-status {
    font-size: 13px;
    color: var(--ordertune-neon-green);
    margin-top: 2px;
}

.ordertune-chat-close-btn {
    background: transparent;
    border: none;
    color: var(--ordertune-text-gray);
    cursor: pointer;
    padding: 8px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ordertune-chat-close-btn:hover {
    background: rgba(197, 255, 0, 0.1);
    color: var(--ordertune-neon-green);
}

.ordertune-chat-close-btn svg {
    width: 20px;
    height: 20px;
}

/* Messages area */
.ordertune-chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* smooth inertia on Mac trackpad & iOS */
    overscroll-behavior: contain;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--ordertune-dark-bg);
    touch-action: pan-y;
    scrollbar-gutter: stable;
    pointer-events: auto; /* ensure wheel events reach this element */
}

.ordertune-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ordertune-chat-messages::-webkit-scrollbar-track {
    background: rgba(197, 255, 0, 0.05);
    border-radius: 4px;
}

.ordertune-chat-messages::-webkit-scrollbar-thumb {
    background: var(--ordertune-neon-green);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.ordertune-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #d4ff33;
    box-shadow: 0 0 8px rgba(197, 255, 0, 0.4);
}

/* Firefox scrollbar styling */
.ordertune-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: var(--ordertune-neon-green) rgba(197, 255, 0, 0.05);
}

/* Message bubbles */
.ordertune-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

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

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

.ordertune-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ordertune-neon-green);
    color: var(--ordertune-darker-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ordertune-message.user .ordertune-message-avatar {
    background: #333;
    color: var(--ordertune-neon-green);
}

.ordertune-message-avatar svg {
    width: 20px;
    height: 20px;
}

.ordertune-message-content {
    max-width: 75%;
}

.ordertune-message-bubble {
    background: var(--ordertune-darker-bg);
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ordertune-text-light);
    word-wrap: break-word;
    border: 1px solid var(--ordertune-border);
}

.ordertune-message.user .ordertune-message-bubble {
    background: var(--ordertune-neon-green);
    color: var(--ordertune-darker-bg);
    border: none;
    font-weight: 500;
}

.ordertune-message-sources {
    margin-top: 10px;
    font-size: 13px;
}

.ordertune-message-source {
    display: block;
    color: var(--ordertune-neon-green);
    text-decoration: none;
    padding: 6px 0;
    transition: opacity 0.2s;
}

.ordertune-message-source:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Typing indicator */
.ordertune-typing-indicator {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

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

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

.ordertune-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(-6px);
    }
}

/* Input area */
.ordertune-chat-input-wrapper {
    border-top: 1px solid var(--ordertune-border);
    padding: 16px;
    background: var(--ordertune-darker-bg);
}

.ordertune-chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ordertune-chat-input {
    flex: 1;
    border: 1px solid var(--ordertune-border);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
    background: var(--ordertune-dark-bg);
    color: var(--ordertune-text-light);
    transition: border-color 0.2s;
}

.ordertune-chat-input::placeholder {
    color: var(--ordertune-text-gray);
}

.ordertune-chat-input:focus {
    outline: none;
    border-color: var(--ordertune-neon-green);
}

.ordertune-chat-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--ordertune-neon-green);
    color: var(--ordertune-darker-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.ordertune-chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(197, 255, 0, 0.4);
}

.ordertune-chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

.ordertune-chat-send-btn svg {
    width: 22px;
    height: 22px;
}

/* Email Collection Form */
.ordertune-email-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.ordertune-email-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--ordertune-neon-green);
    border-radius: 8px;
    background: var(--ordertune-darker-bg);
    color: var(--ordertune-text-light);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.ordertune-email-input::placeholder {
    color: var(--ordertune-text-gray);
}

.ordertune-email-input:focus {
    outline: none;
    border-color: var(--ordertune-neon-green);
    box-shadow: 0 0 0 3px rgba(197, 255, 0, 0.1);
}

.ordertune-email-submit {
    width: 100%;
    padding: 12px 20px;
    background: var(--ordertune-neon-green);
    color: var(--ordertune-darker-bg);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.ordertune-email-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(197, 255, 0, 0.3);
}

.ordertune-email-submit:active:not(:disabled) {
    transform: translateY(0);
}

.ordertune-email-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .ordertune-chatbot-widget {
        bottom: 16px;
        right: 16px;
        left: auto;
    }

    .ordertune-chat-button {
        width: 40px;
        height: 40px;
    }

    .ordertune-chat-icon,
    .ordertune-close-icon {
        width: 20px;
        height: 20px;
    }

    .ordertune-chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .ordertune-message-content {
        max-width: 80%;
    }
}

/* Tablet */
@media (max-width: 768px) and (min-width: 481px) {
    .ordertune-chat-window {
        width: 360px;
        height: 550px;
    }
}

/* Dark theme optimization */
@media (prefers-color-scheme: dark) {
    .ordertune-chat-window {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(197, 255, 0, 0.1);
    }
}

/* Feedback buttons */
.ordertune-feedback-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    opacity: 0;
    animation: fadeInFeedback 0.3s ease-out 2s forwards;
}

@keyframes fadeInFeedback {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ordertune-feedback-btn {
    background: transparent;
    border: 1px solid var(--ordertune-border);
    border-radius: 8px;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--ordertune-text-gray);
}

.ordertune-feedback-btn:hover:not(:disabled) {
    background: rgba(197, 255, 0, 0.1);
    border-color: var(--ordertune-neon-green);
    color: var(--ordertune-neon-green);
    transform: translateY(-1px);
}

.ordertune-feedback-btn.active {
    background: var(--ordertune-neon-green);
    border-color: var(--ordertune-neon-green);
    color: var(--ordertune-darker-bg);
}

.ordertune-feedback-btn.active svg {
    stroke: var(--ordertune-darker-bg);
}

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

.ordertune-feedback-icon {
    display: flex;
    align-items: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Email nudge — compact trigger that expands on click */
.ordertune-nudge {
    margin-left: 46px; /* align with bot bubble (avatar 36px + gap 10px) */
    margin-top: -8px;
    margin-bottom: 4px;
}

.ordertune-nudge-trigger {
    background: transparent;
    border: 1px dashed var(--ordertune-neon-green);
    border-radius: 20px;
    color: var(--ordertune-neon-green);
    font-size: 13px;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: var(--ordertune-font-family);
    white-space: nowrap;
}

.ordertune-nudge-trigger:hover {
    background: rgba(197, 255, 0, 0.08);
}

/* Expanded inline form — hidden by default, JS sets display:flex */
.ordertune-nudge-form {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.ordertune-nudge-email {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 14px;
    border: 1px solid var(--ordertune-neon-green);
    border-radius: 8px;
    background: var(--ordertune-darker-bg);
    color: var(--ordertune-text-light);
    font-size: 14px;
    font-family: var(--ordertune-font-family);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ordertune-nudge-email::placeholder {
    color: var(--ordertune-text-gray);
}

.ordertune-nudge-email:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(197, 255, 0, 0.2);
}

.ordertune-nudge-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ordertune-nudge-submit {
    flex: 1;
    padding: 9px 16px;
    background: var(--ordertune-neon-green);
    color: var(--ordertune-darker-bg);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-family: var(--ordertune-font-family);
}

.ordertune-nudge-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(197, 255, 0, 0.3);
}

.ordertune-nudge-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ordertune-nudge-cancel {
    width: 34px;
    height: 34px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--ordertune-border);
    border-radius: 6px;
    color: var(--ordertune-text-gray);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, color 0.2s;
    flex-shrink: 0;
}

.ordertune-nudge-cancel:hover {
    border-color: var(--ordertune-text-gray);
    color: var(--ordertune-text-light);
}

.ordertune-nudge-done {
    font-size: 13px;
    color: var(--ordertune-neon-green);
}
