/*
 * Chat Widget CSS for Bytesweavers AI Chat Master plugin.
 * This file styles the front-end chat widget.
 */

 #aicw-container {
    --primary-color: #007bff;
    --primary-color-light: #e6f2ff;
    --primary-color-dark: #0056b3;
    --bg-color: #ffffff;
    --text-color: #333333;
    --light-gray: #f0f2f5;
    --border-color: #e4e6eb;
    --shadow-color: rgba(0, 0, 0, 0.15);
    --message-shadow: rgba(0, 0, 0, 0.05);
    --user-msg-gradient: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark));
    --assistant-msg-gradient: linear-gradient(135deg, #f8f9fa, #eaecef);
    --transition-speed: 0.3s;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.aicw-widget {
    position: fixed;
    width: 380px;
    height: 600px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    background: var(--bg-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    z-index: 999999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition-speed) ease, opacity var(--transition-speed) ease;
    transform: translateY(20px);
    opacity: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.aicw-widget.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

/* Position classes */
.aicw-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.aicw-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.aicw-position-top-right {
    top: 20px;
    right: 20px;
}

.aicw-position-top-left {
    top: 20px;
    left: 20px;
}

.aicw-toggle {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--user-msg-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 999998;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.aicw-toggle:hover {
    transform: scale(1.1) rotate(5deg);
}

.aicw-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.aicw-hover-message {
    position: absolute;
    background: white;
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    pointer-events: none;
    border: 1px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999997;
}

.aicw-position-bottom-right .aicw-hover-message {
    bottom: calc(100% + 10px);
    right: 0;
    transform: translateY(10px);
}

.aicw-position-bottom-left .aicw-hover-message {
    bottom: calc(100% + 10px);
    left: 0;
    transform: translateY(10px);
}

.aicw-position-top-right .aicw-hover-message {
    top: calc(100% + 10px);
    right: 0;
    transform: translateY(-10px);
}

.aicw-position-top-left .aicw-hover-message {
    top: calc(100% + 10px);
    left: 0;
    transform: translateY(-10px);
}

.aicw-toggle:hover .aicw-hover-message {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.aicw-hover-message::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    transform: rotate(45deg);
    border: 1px solid var(--border-color);
}

.aicw-position-bottom-right .aicw-hover-message::after,
.aicw-position-bottom-left .aicw-hover-message::after {
    bottom: -6px;
    border-top: none;
    border-left: none;
}

.aicw-position-top-right .aicw-hover-message::after,
.aicw-position-top-left .aicw-hover-message::after {
    top: -6px;
    border-bottom: none;
    border-right: none;
}

.aicw-position-bottom-right .aicw-hover-message::after,
.aicw-position-top-right .aicw-hover-message::after {
    right: 25px;
}

.aicw-position-bottom-left .aicw-hover-message::after,
.aicw-position-top-left .aicw-hover-message::after {
    left: 25px;
}

.aicw-position-bottom-left .aicw-hover-message {
    left: 0;
    right: auto;
}

.aicw-position-bottom-left .aicw-hover-message:after {
    left: 24px;
    right: auto;
}

.aicw-position-top-right .aicw-hover-message,
.aicw-position-top-left .aicw-hover-message {
    top: auto;
    bottom: -45px;
}

.aicw-position-top-right .aicw-hover-message:after,
.aicw-position-top-left .aicw-hover-message:after {
    top: -6px;
    bottom: auto;
    border-top: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
    border-right: none;
    border-bottom: none;
}

.aicw-menu {
    cursor: pointer;
    display: flex;
    align-items: center;
    position: relative;
}

.aicw-menu svg {
    width: 24px;
    height: 24px;
    fill: white;
    transition: transform 0.2s ease;
}

.aicw-menu:hover svg {
    transform: scale(1.1);
}

.aicw-menu-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aicw-menu-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--border-radius-sm);
    min-width: 200px;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    animation: aicw-fadeIn 0.2s ease;
}

@keyframes aicw-fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.aicw-menu-dropdown ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.aicw-menu-dropdown li {
    padding: 10px 14px;
    cursor: pointer;
    color: #333333;
    font-size: 13px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    margin: 0;
}

.aicw-menu-dropdown li:hover {
    background-color: var(--primary-color-light);
    color: var(--primary-color-dark);
    padding-left: 22px;
}

.aicw-menu-dropdown li:last-child {
    border-bottom: none;
}

.aicw-header {
    padding: 20px 24px;
    background: var(--user-msg-gradient);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.aicw-header-text {
    flex: 1;
}

.aicw-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.aicw-subtitle {
    margin: 4px 0 0;
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
}

.aicw-header-actions {
    display: flex;
    align-items: center;
}

.aicw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-color);
    scroll-behavior: smooth;
    background-image: radial-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px);
    background-size: 20px 20px;
}

.aicw-message {
    margin-bottom: 16px;
    max-width: 85%;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    animation: aicw-message-appear 0.3s ease;
}

@keyframes aicw-message-appear {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

.aicw-message:last-child {
    margin-bottom: 0;
}

.aicw-message.user {
    margin-left: auto;
}

.aicw-message.assistant {
    margin-right: auto;
}

.aicw-message-content {
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    margin: 0;
    white-space: normal;
    display: inline-block;
    box-shadow: 0 2px 10px var(--message-shadow);
}

.aicw-message-content p {
    margin: 0;
    padding: 0;
}

.aicw-message.user .aicw-message-content {
    background: var(--user-msg-gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.aicw-message.assistant .aicw-message-content {
    background: var(--assistant-msg-gradient);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    line-height: 1.6;
}

.aicw-message.assistant .aicw-message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.aicw-message.assistant .aicw-message-content li {
    margin: 4px 0;
}

.aicw-message.assistant .aicw-message-content a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid var(--primary-color);
}

.aicw-message.assistant .aicw-message-content a:hover {
    opacity: 0.8;
}

.aicw-message.assistant .aicw-message-content strong {
    font-weight: 600;
}

.aicw-message.assistant .aicw-message-content em {
    font-style: italic;
}

.aicw-message.assistant .aicw-message-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 16px 0 8px;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.aicw-message.assistant .aicw-message-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 14px 0 6px;
    color: var(--text-color);
}

.aicw-message.assistant .aicw-message-content hr {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

.aicw-message.assistant .aicw-message-content ul {
    margin: 8px 0;
    padding-left: 20px;
    list-style-type: disc;
}

.aicw-message.assistant .aicw-message-content ul ul {
    margin: 4px 0;
}

.aicw-message.assistant .aicw-message-content li {
    margin: 4px 0;
    line-height: 1.4;
}

.aicw-message.assistant .aicw-message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.aicw-message.assistant .aicw-message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 10px 0;
}

.aicw-message.assistant .aicw-message-content pre code {
    background: none;
    padding: 0;
    display: block;
    line-height: 1.5;
}

.aicw-message.assistant .aicw-message-content ul,
.aicw-message.assistant .aicw-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.aicw-message.assistant .aicw-message-content ul li {
    list-style-type: disc;
    margin: 4px 0;
}

.aicw-message.assistant .aicw-message-content ol li {
    list-style-type: decimal;
    margin: 4px 0;
}

.aicw-message-time {
    font-size: 11px;
    color: #8e8e8e;
    margin-top: 4px;
    padding: 0 4px;
    line-height: 1;
}

.aicw-typing {
    padding: 12px 20px;
    display: none;
    align-items: center;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    animation: aicw-slideUp 0.3s ease;
}

@keyframes aicw-slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.aicw-typing-indicator {
    display: flex;
    align-items: center;
    margin-right: 10px;
}

.aicw-typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--primary-color);
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
    opacity: 0.7;
}

.aicw-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.aicw-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.aicw-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.aicw-typing-text {
    color: #65676B;
    font-size: 13px;
    font-weight: 500;
}

.aicw-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.aicw-input-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.aicw-input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid var(--border-color);
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
    background: #f8f9fa;
}

.aicw-input:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-color-light);
}

.aicw-send {
    width: 48px;
    height: 48px;
    min-width: 48px;
    background: var(--user-msg-gradient);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.aicw-send:hover {
    transform: scale(1.05) rotate(5deg);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.aicw-send:active {
    transform: scale(0.95);
}

.aicw-send svg {
    width: 22px;
    height: 22px;
    fill: white;
    margin-left: 2px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.aicw-button-disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

.aicw-default-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.2);
}

.aicw-default-logo svg {
    width: 100%;
    height: 100%;
    color: rgba(255, 255, 255, 0.9);
}

.aicw-online-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.aicw-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2);
    animation: pulse 2s infinite;
}

.aicw-status-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(46, 204, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

@media (max-width: 480px) {
    .aicw-widget {
        width: 100% !important;
        height: 100% !important;
        max-width: 100%;
        max-height: 100%;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0;
        animation: aicw-slide-up 0.3s ease;
    }
    
    @keyframes aicw-slide-up {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    
    .aicw-header {
        border-radius: 0;
        padding: 16px 20px;
    }
    
    .aicw-toggle {
        bottom: 20px;
        right: 20px;
    }
    
    .aicw-input-container {
        padding: 12px 16px;
    }
}

.aicw-title-container {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.aicw-title-text {
    display: flex;
    flex-direction: column;
}

.aicw-close svg {
    width: 24px;
    height: 24px;
    fill: white !important;
    transition: transform 0.2s ease;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.aicw-close:hover svg {
    transform: scale(1.1);
}

.aicw-close-form {
    position: absolute;
    right: 15px;
    top: 15px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.aicw-close-form:hover {
    background: rgba(0, 0, 0, 0.1);
}

.aicw-close-form svg {
    width: 18px;
    height: 18px;
    fill: #666 !important;
}

.aicw-toggle.aicw-animate-enabled:hover {
    transform: scale(1.1) rotate(5deg);
}

.aicw-toggle.aicw-animate-disabled:hover {
    transform: scale(1.05);
}