/*
=========================================================
MARQS SPORT AI CHATBOT CSS
Enhanced Version with AI Assistant Branding
=========================================================
*/

/*
=========================================================
MAIN CONTAINER
=========================================================
*/

#marqs-chatbot {
    position: fixed;
    left: 25px;
    bottom: 25px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/*
=========================================================
FLOATING CHAT BUTTON
=========================================================
*/

#marqs-chat-toggle {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(17, 24, 39, 0.35);
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(255, 255, 255, 0.1);
    outline: none;
    position: relative;
    z-index: 999998;
}

#marqs-chat-toggle::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity .3s ease;
}

#marqs-chat-toggle:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 15px 40px rgba(17, 24, 39, 0.4);
}

#marqs-chat-toggle:hover::after {
    opacity: 1;
}

#marqs-chat-toggle:active {
    transform: scale(0.92);
}

#marqs-chat-toggle.hidden {
    display: none;
}

/* Pulse animation for attention */
#marqs-chat-toggle.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(17, 24, 39, 0.4);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(17, 24, 39, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(17, 24, 39, 0);
    }
}

/*
=========================================================
CHAT WINDOW
=========================================================
*/

#marqs-chat-window {
    width: 400px;
    height: 620px;
    max-height: 85vh;
    background: white;
    border-radius: 24px;
    position: absolute;
    left: 0;
    bottom: 85px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    animation: marqsOpen .35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999999;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#marqs-chat-window.active {
    display: flex;
}

@keyframes marqsOpen {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes marqsClose {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(30px) scale(0.92);
    }
}

/*
=========================================================
HEADER
=========================================================
*/

.marqs-header {
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

/* Animated gradient overlay */
.marqs-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.marqs-title {
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.marqs-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.marqs-title-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.marqs-title-main {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.marqs-title-sub {
    font-size: 10px;
    font-weight: 400;
    opacity: 0.7;
    letter-spacing: 0.5px;
}

.marqs-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    opacity: 0.8;
    position: relative;
    z-index: 1;
}

.marqs-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.8);
    }
}

#marqs-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all .2s ease;
    line-height: 1;
    position: relative;
    z-index: 1;
}

#marqs-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

#marqs-close:active {
    transform: rotate(90deg) scale(0.9);
}

/*
=========================================================
MESSAGE AREA
=========================================================
*/

#marqs-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    scroll-behavior: smooth;
}

#marqs-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

#marqs-chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #cbd5e1, #94a3b8);
    border-radius: 10px;
}

#marqs-chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #94a3b8, #64748b);
}

/* Scrollbar for Firefox */
#marqs-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/*
=========================================================
MESSAGES
=========================================================
*/

.marqs-message {
    display: flex;
    margin-bottom: 16px;
    animation: messageSlide .4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.marqs-user {
    justify-content: flex-end;
}

.marqs-bot {
    justify-content: flex-start;
}

.marqs-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
    transition: all .2s ease;
}

.marqs-user .marqs-bubble {
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 12px rgba(17, 24, 39, 0.15);
}

.marqs-user .marqs-bubble::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 12px;
    height: 12px;
    background: #1f2937;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.marqs-bot .marqs-bubble {
    background: white;
    color: #111827;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.marqs-bot .marqs-bubble::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 12px;
    height: 12px;
    background: white;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
}

/*
=========================================================
TIMESTAMP
=========================================================
*/

.marqs-time {
    margin-top: 6px;
    font-size: 10px;
    opacity: 0.5;
    text-align: right;
    letter-spacing: 0.3px;
    font-weight: 500;
}

.marqs-bot .marqs-time {
    text-align: left;
    padding-left: 4px;
}

/*
=========================================================
TYPING INDICATOR
=========================================================
*/

#marqs-typing {
    display: none;
    gap: 8px;
    padding: 12px 20px;
    align-items: center;
    animation: messageSlide .3s ease;
}

#marqs-typing .typing-text {
    font-size: 12px;
    color: #64748b;
    margin-right: 4px;
    font-weight: 500;
}

#marqs-typing .dots {
    display: flex;
    gap: 5px;
}

#marqs-typing span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #94a3b8, #64748b);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

#marqs-typing span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px) scale(1.2);
        opacity: 1;
    }
}

/*
=========================================================
INPUT AREA
=========================================================
*/

.marqs-input-area {
    display: flex;
    padding: 14px 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
    gap: 10px;
    align-items: flex-end;
}

#marqs-message {
    flex: 1;
    border: 2px solid #d1d5db;
    border-radius: 25px;
    padding: 12px 18px;
    outline: none;
    font-size: 14px;
    transition: all .3s ease;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    background: #fafafa;
}

#marqs-message:focus {
    border-color: #111827;
    box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.08);
    background: white;
}

#marqs-message::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

#marqs-message:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
    opacity: 0.7;
}

#marqs-send {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    color: white;
    cursor: pointer;
    font-size: 20px;
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(17, 24, 39, 0.2);
    position: relative;
    overflow: hidden;
}

#marqs-send::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    opacity: 0;
    transition: opacity .3s ease;
}

#marqs-send:hover:not(:disabled) {
    transform: scale(1.08) rotate(-5deg);
    box-shadow: 0 4px 20px rgba(17, 24, 39, 0.3);
}

#marqs-send:hover:not(:disabled)::after {
    opacity: 0.15;
}

#marqs-send:active:not(:disabled) {
    transform: scale(0.92);
}

#marqs-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(0.95);
}

#marqs-send .send-icon {
    position: relative;
    z-index: 1;
}

/*
=========================================================
PRODUCT LIST
=========================================================
*/

.marqs-products {
    width: 100%;
    animation: messageSlide .4s ease;
    margin-top: 4px;
}

.marqs-products-title {
    margin-bottom: 16px;
    font-size: 15px;
    padding: 0 4px;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 8px;
}

.marqs-products-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, #e5e7eb, transparent);
}

/*
=========================================================
PRODUCT CARD
=========================================================
*/

.marqs-product-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.marqs-product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    opacity: 0;
    transition: opacity .3s ease;
}

.marqs-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.marqs-product-card:hover::before {
    opacity: 1;
}

.marqs-product-card:active {
    transform: translateY(0) scale(0.99);
}

.marqs-product-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    line-height: 1.3;
}

.marqs-product-name a {
    color: #111827;
    text-decoration: none;
    transition: color .2s ease;
}

.marqs-product-name a:hover {
    color: #3b82f6;
    text-decoration: underline;
}

.marqs-price {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 12px;
    color: #16a34a;
    letter-spacing: -0.5px;
}

.marqs-price::before {
    content: "£";
    font-weight: 700;
}

.marqs-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    padding: 7px 0;
    border-bottom: 1px solid #f1f5f9;
}

.marqs-row:last-of-type {
    border-bottom: none;
}

.marqs-row strong {
    color: #475569;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.marqs-row span {
    font-weight: 500;
}

/*
=========================================================
STOCK BADGES
=========================================================
*/

.stock-in {
    color: #16a34a;
    font-weight: 700;
    background: #dcfce7;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
}

.stock-in::before {
    content: "✓ ";
}

.stock-out {
    color: #dc2626;
    font-weight: 700;
    background: #fee2e2;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
}

.stock-out::before {
    content: "✕ ";
}

/*
=========================================================
PRODUCT BUTTON
=========================================================
*/

.marqs-buttons {
    margin-top: 14px;
}

.marqs-view-btn {
    display: block;
    text-align: center;
    padding: 11px;
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    color: white;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.marqs-view-btn::after {
    content: '→';
    margin-left: 8px;
    transition: transform .3s ease;
    display: inline-block;
}

.marqs-view-btn:hover {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(17, 24, 39, 0.2);
}

.marqs-view-btn:hover::after {
    transform: translateX(4px);
}

.marqs-view-btn:active {
    transform: translateY(0) scale(0.98);
}

/*
=========================================================
LINKS INSIDE BOT MESSAGE
=========================================================
*/

.marqs-bubble a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: all .2s ease;
}

.marqs-bubble a:hover {
    border-bottom-color: #3b82f6;
    color: #2563eb;
}

/*
=========================================================
DARK MODE SUPPORT
=========================================================
*/

@media (prefers-color-scheme: dark) {
    #marqs-chat-window {
        background: #1a1a2e;
        border-color: rgba(255, 255, 255, 0.05);
    }

    #marqs-chat-messages {
        background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    }

    .marqs-bot .marqs-bubble {
        background: #2d2d44;
        color: #e2e8f0;
        border-color: rgba(255, 255, 255, 0.05);
    }

    .marqs-bot .marqs-bubble::before {
        background: #2d2d44;
    }

    .marqs-user .marqs-bubble {
        background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    }

    .marqs-user .marqs-bubble::after {
        background: #8b5cf6;
    }

    .marqs-product-card {
        background: #2d2d44;
        border-color: rgba(255, 255, 255, 0.05);
    }

    .marqs-product-name a {
        color: #e2e8f0;
    }

    .marqs-product-name a:hover {
        color: #60a5fa;
    }

    .marqs-row {
        border-bottom-color: rgba(255, 255, 255, 0.05);
    }

    .marqs-row strong {
        color: #94a3b8;
    }

    .marqs-input-area {
        background: #1a1a2e;
        border-top-color: rgba(255, 255, 255, 0.05);
    }

    #marqs-message {
        background: #2d2d44;
        border-color: rgba(255, 255, 255, 0.1);
        color: #e2e8f0;
    }

    #marqs-message:focus {
        border-color: #3b82f6;
        background: #2d2d44;
    }

    #marqs-message::placeholder {
        color: #64748b;
    }

    .marqs-products-title {
        color: #e2e8f0;
    }

    .marqs-products-title::after {
        background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), transparent);
    }
}

/*
=========================================================
MOBILE RESPONSIVE
=========================================================
*/

@media (max-width: 600px) {
    #marqs-chatbot {
        right: 12px;
        bottom: 12px;
    }

    #marqs-chat-toggle {
        width: 58px;
        height: 58px;
        font-size: 26px;
    }

    #marqs-chat-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 130px);
        max-height: none;
        right: 0;
        bottom: 80px;
        border-radius: 18px;
    }

    .marqs-bubble {
        max-width: 92%;
        font-size: 15px;
        padding: 11px 15px;
    }

    .marqs-title {
        font-size: 15px;
        gap: 10px;
    }

    .marqs-title-main {
        font-size: 14px;
    }

    .marqs-title-sub {
        font-size: 9px;
    }

    .marqs-logo {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .marqs-header {
        padding: 12px 16px;
    }

    #marqs-chat-messages {
        padding: 14px;
    }

    #marqs-message {
        font-size: 16px;
        padding: 10px 14px;
        min-height: 40px;
    }

    .marqs-input-area {
        padding: 10px 12px;
        gap: 8px;
    }

    #marqs-send {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .marqs-product-card {
        padding: 14px;
    }

    .marqs-product-name {
        font-size: 15px;
    }

    .marqs-price {
        font-size: 18px;
    }

    .marqs-products-title {
        font-size: 14px;
    }

    #marqs-typing .typing-text {
        font-size: 11px;
    }

    .marqs-status {
        font-size: 9px;
    }
}

@media (max-width: 400px) {
    #marqs-chat-window {
        height: calc(100vh - 110px);
        bottom: 70px;
        width: calc(100vw - 16px);
        right: 0;
        border-radius: 14px;
    }

    #marqs-chat-toggle {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }

    .marqs-bubble {
        font-size: 14px;
        padding: 10px 13px;
    }
}

/*
=========================================================
ACCESSIBILITY
=========================================================
*/

@media (prefers-reduced-motion: reduce) {
    #marqs-chat-window,
    .marqs-message,
    .marqs-product-card,
    #marqs-chat-toggle,
    .marqs-view-btn,
    #marqs-send,
    .marqs-header::before {
        animation: none;
        transition: none !important;
    }

    #marqs-chat-toggle:hover {
        transform: none;
    }

    #marqs-chat-toggle.pulse {
        animation: none;
    }
}

/* Focus styles for accessibility */
#marqs-chat-toggle:focus-visible,
#marqs-close:focus-visible,
#marqs-message:focus-visible,
#marqs-send:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast support */
@media (prefers-contrast: high) {
    .marqs-bubble {
        border: 2px solid currentColor;
    }
    
    .marqs-product-card {
        border: 2px solid currentColor;
    }
}

/*
=========================================================
PRINT STYLES
=========================================================
*/

@media print {
    #marqs-chatbot {
        display: none !important;
    }
}