/**
 * WC AI Assistant - Widget Styles
 *
 * @package WC_AI_Assistant
 */

:root {
    --wcai-primary-color: #0073aa;
    --wcai-primary-hover: #005a87;
    --wcai-bg-light: #ffffff;
    --wcai-bg-gray: #f7f8fa;
    --wcai-text-dark: #1a1a1a;
    --wcai-text-gray: #6c757d;
    --wcai-border: #e1e8ed;
    --wcai-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --wcai-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Main Widget Container */
.wcai-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wcai-widget.wcai-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wcai-widget.wcai-bottom-left {
    bottom: 20px;
    left: 20px;
}

.wcai-widget.wcai-top-right {
    top: 20px;
    right: 20px;
}

.wcai-widget.wcai-top-left {
    top: 20px;
    left: 20px;
}

/* Toggle Button */
.wcai-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--wcai-primary-color);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--wcai-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.wcai-toggle:hover {
    background-color: var(--wcai-primary-hover);
    transform: scale(1.05);
    box-shadow: var(--wcai-shadow-lg);
}

.wcai-toggle:active {
    transform: scale(0.95);
}

.wcai-toggle svg {
    width: 28px;
    height: 28px;
    transition: all 0.3s;
}

.wcai-toggle .wcai-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
}

.wcai-toggle .wcai-icon-chat {
    opacity: 1;
    transform: rotate(0deg);
}

.wcai-toggle.wcai-open .wcai-icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

.wcai-toggle.wcai-open .wcai-icon-chat {
    opacity: 0;
    transform: rotate(90deg);
}

/* Chat Window */
.wcai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--wcai-bg-light);
    border-radius: 16px;
    box-shadow: var(--wcai-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.wcai-header {
    background: var(--wcai-primary-color);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.wcai-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wcai-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.wcai-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.wcai-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.wcai-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4ade80;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.wcai-btn-minimize {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.wcai-btn-minimize:hover {
    background: rgba(255, 255, 255, 0.1);
}

.wcai-btn-minimize svg {
    width: 20px;
    height: 20px;
}

/* Messages Container */
.wcai-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--wcai-bg-gray);
}

.wcai-messages::-webkit-scrollbar {
    width: 6px;
}

.wcai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wcai-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.wcai-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message */
.wcai-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.wcai-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.wcai-message-assistant {
    align-self: flex-start;
}

.wcai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--wcai-primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wcai-message-avatar svg {
    width: 20px;
    height: 20px;
}

.wcai-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.wcai-message-content {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

.wcai-message-text {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

.wcai-message-text pre,
.wcai-message-text code {
    overflow-x: auto;
    max-width: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.wcai-message-user .wcai-message-text {
    background: var(--wcai-primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.wcai-message-assistant .wcai-message-text {
    background: white;
    color: var(--wcai-text-dark);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    opacity: 1;
}

.wcai-message-assistant .wcai-message-text * {
    opacity: 1 !important;
}

/* Markdown Styling */
.wcai-markdown {
    color: var(--wcai-text-dark);
    opacity: 1;
}

.wcai-markdown p {
    margin: 0 0 8px 0;
    color: var(--wcai-text-dark);
    opacity: 1;
}

.wcai-markdown p:last-child {
    margin-bottom: 0;
}

.wcai-markdown strong {
    font-weight: 600;
    color: var(--wcai-text-dark);
}

.wcai-markdown em {
    font-style: italic;
    color: var(--wcai-text-dark);
}

.wcai-markdown a {
    color: var(--wcai-primary-color);
    text-decoration: underline;
}

.wcai-markdown a:hover {
    color: var(--wcai-primary-hover);
}

.wcai-markdown ul,
.wcai-markdown ol {
    margin: 8px 0;
    padding-left: 20px;
    color: var(--wcai-text-dark);
}

.wcai-markdown li {
    margin: 4px 0;
    color: var(--wcai-text-dark);
}

.wcai-markdown code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #e11d48;
}

.wcai-markdown pre {
    background: #1e293b;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.wcai-markdown pre code {
    background: transparent;
    color: #e2e8f0;
    padding: 0;
    font-size: 13px;
    display: block;
}

.wcai-markdown h1,
.wcai-markdown h2,
.wcai-markdown h3,
.wcai-markdown h4,
.wcai-markdown h5,
.wcai-markdown h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    color: var(--wcai-text-dark);
    opacity: 1;
}

.wcai-markdown h1 { font-size: 20px; }
.wcai-markdown h2 { font-size: 18px; }
.wcai-markdown h3 { font-size: 16px; }
.wcai-markdown h4 { font-size: 15px; }
.wcai-markdown h5 { font-size: 14px; }
.wcai-markdown h6 { font-size: 13px; }

.wcai-markdown blockquote {
    border-left: 3px solid var(--wcai-primary-color);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--wcai-text-gray);
    font-style: italic;
}

.wcai-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}

.wcai-markdown table th,
.wcai-markdown table td {
    border: 1px solid var(--wcai-border);
    padding: 8px;
    text-align: left;
}

.wcai-markdown table th {
    background: var(--wcai-bg-gray);
    font-weight: 600;
}

/* Typing Indicator */
.wcai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    width: fit-content;
    margin-left: 44px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wcai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--wcai-text-gray);
    animation: typing 1.4s infinite;
}

.wcai-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.wcai-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Form */
.wcai-form {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--wcai-border);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.wcai-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--wcai-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.wcai-input:focus {
    border-color: var(--wcai-primary-color);
}

.wcai-input::placeholder {
    color: var(--wcai-text-gray);
}

.wcai-btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--wcai-primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.wcai-btn-send:hover {
    background: var(--wcai-primary-hover);
    transform: scale(1.05);
}

.wcai-btn-send:active {
    transform: scale(0.95);
}

.wcai-btn-send svg {
    width: 20px;
    height: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .wcai-chat-window {
        position: fixed;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        border-radius: 0;
        animation: slideUpMobile 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideUpMobile {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .wcai-widget.wcai-bottom-left {
        bottom: 20px;
        left: 20px;
        right: auto;
    }

    .wcai-widget.wcai-bottom-right {
        bottom: 20px;
        right: 20px;
        left: auto;
    }

    .wcai-widget.wcai-top-left {
        top: 20px;
        left: 20px;
        right: auto;
        bottom: auto;
    }

    .wcai-widget.wcai-top-right {
        top: 20px;
        right: 20px;
        left: auto;
        bottom: auto;
    }

    /* Hide toggle button when chat is open on mobile */
    .wcai-widget.wcai-mobile-open .wcai-toggle {
        display: none;
    }

    .wcai-messages {
        padding: 16px;
    }

    .wcai-form {
        padding: 12px 16px;
    }

    .wcai-message {
        max-width: 90%;
    }
}

/* Accessibility */
.wcai-toggle:focus,
.wcai-btn-minimize:focus,
.wcai-btn-send:focus,
.wcai-input:focus {
    outline: 2px solid var(--wcai-primary-color);
    outline-offset: 2px;
}

/* Admin Message Notification Popup */
.wcai-admin-notification {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 999998;
    max-width: 350px;
    animation: wcai-slide-in 0.3s ease-out;
}

@keyframes wcai-slide-in {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.wcai-admin-notification-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    overflow: hidden;
    color: white;
}

.wcai-admin-notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.wcai-admin-notification-header strong {
    font-size: 14px;
    font-weight: 600;
}

.wcai-admin-notification-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.wcai-admin-notification-close:hover {
    opacity: 1;
}

.wcai-admin-notification-body {
    padding: 15px 20px;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.95);
}

.wcai-admin-notification-open {
    width: 100%;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.wcai-admin-notification-open:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Notification Bell Styles */
.wcai-btn-action {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.wcai-btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
}

.wcai-btn-action svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: all 0.2s;
}

.wcai-btn-action.wcai-notifications-disabled {
    opacity: 0.5;
}

.wcai-btn-action.wcai-notifications-disabled svg {
    fill: rgba(255, 255, 255, 0.6);
}

.wcai-btn-action.wcai-notifications-disabled:hover {
    opacity: 0.7;
}

.wcai-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Print styles */
@media print {
    .wcai-widget,
    .wcai-admin-notification {
        display: none !important;
    }
}
