/**
 * FlexChat Widget Styles - Modern Design
 * Uses FlexSuite Core CSS variables
 */

.flexchat-widget {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.flexchat-button {
    background: linear-gradient(135deg, var(--flexsuite-primary, #1E55B3) 0%, var(--flexsuite-primary-hover, #1a4a9a) 100%);
    color: white;
    padding: 16px 24px;
    border-radius: var(--flexsuite-border-radius, 8px);
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(30, 85, 179, 0.3);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    position: relative;
    overflow: hidden;
}

.flexchat-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.flexchat-button:hover::before {
    left: 100%;
}

.flexchat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(30, 85, 179, 0.4);
}

.flexchat-button-icon {
    font-size: 22px;
    line-height: 1;
}

.flexchat-button-text {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.3px;
}

.flexchat-window {
    position: absolute;
    bottom: calc(100% + 20px);
    left: 0;
    width: 420px;
    max-width: calc(100vw - 40px);
    height: auto;
    min-height: auto;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: var(--flexsuite-border-radius, 8px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    overflow: visible;
    display: flex;
    flex-direction: column;
    animation: flexchat-slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.flexchat-window.has-chat {
    height: 680px;
    min-height: 680px;
}

@keyframes flexchat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flexchat-header {
    background: linear-gradient(135deg, var(--flexsuite-primary, #1E55B3) 0%, var(--flexsuite-primary-hover, #1a4a9a) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    border-radius: var(--flexsuite-border-radius, 8px) var(--flexsuite-border-radius, 8px) 0 0;
    overflow: hidden;
}

.flexchat-header-info {
    color: white;
    flex: 1;
    text-align: center;
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
}

.flexchat-header-info h3,
.flexchat-header-info .flexchat-status {
    pointer-events: auto;
}

.flexchat-header-info h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: white !important;
}

.flexchat-status {
    font-size: 12px;
    opacity: 0.9;
    color: white;
}

.flexchat-close {
    background: linear-gradient(135deg, var(--flexsuite-primary, #1E55B3) 0%, var(--flexsuite-primary-hover, #1a4a9a) 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    position: absolute;
    top: -18px;
    right: -18px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.flexchat-close:hover {
    background: linear-gradient(135deg, var(--flexsuite-primary-hover, #1a4a9a) 0%, var(--flexsuite-primary, #1E55B3) 100%);
    transform: rotate(90deg);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* Visitor Form Styles */
.flexchat-visitor-form {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 20px;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    overflow: visible;
}

.flexchat-form-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.flexchat-form-intro {
    font-size: 16px;
    color: var(--flexsuite-text, #1a202c);
    margin: 0 0 24px 0;
    padding: 0;
    text-align: center;
    line-height: 1.6;
}

.flexchat-form-field {
    margin-bottom: 20px;
}

.flexchat-form-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--flexsuite-text, #1a202c);
    margin-bottom: 8px;
}

.flexchat-form-field .required {
    color: #e53e3e;
}

.flexchat-form-field .optional {
    font-weight: 400;
    font-size: 12px;
    color: var(--flexsuite-text-muted, #718096);
}

.flexchat-form-field input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--flexsuite-border, #e2e8f0);
    border-radius: var(--flexsuite-border-radius, 8px);
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s;
    background: white;
    box-sizing: border-box;
}

.flexchat-form-field input:focus {
    outline: none;
    border-color: var(--flexsuite-primary, #1E55B3);
    box-shadow: 0 0 0 3px rgba(30, 85, 179, 0.1);
}

.flexchat-form-submit {
    width: 100%;
    background: linear-gradient(135deg, var(--flexsuite-primary, #1E55B3) 0%, var(--flexsuite-primary-hover, #1a4a9a) 100%);
    color: white;
    border: none;
    padding: 16px;
    border-radius: var(--flexsuite-border-radius, 8px);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(30, 85, 179, 0.3);
    margin-top: 8px;
}

.flexchat-form-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(30, 85, 179, 0.4);
}

.flexchat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

.flexchat-messages::-webkit-scrollbar {
    width: 6px;
}

.flexchat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.flexchat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: calc(var(--flexsuite-border-radius, 8px) * 0.375);
}

.flexchat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

.flexchat-message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: var(--flexsuite-border-radius, 8px);
    max-width: 80%;
    word-wrap: break-word;
    animation: flexchat-message-fade-in 0.3s ease-out;
    line-height: 1.5;
}

@keyframes flexchat-message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flexchat-message-visitor {
    background: transparent;
    color: var(--flexsuite-text, #1a202c);
    margin-left: auto;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-bottom-right-radius: var(--flexsuite-border-radius, 8px);
}

.flexchat-message-agent,
.flexchat-message-ai {
    background: transparent;
    color: var(--flexsuite-text, #1a202c);
    border: 1px solid rgba(0, 0, 0, 0.08);
    margin-right: auto;
    border-bottom-left-radius: var(--flexsuite-border-radius, 8px);
}

.flexchat-message-ai {
    border-left: 3px solid var(--flexsuite-success, #4caf50);
}

.flexchat-message-system {
    text-align: center;
    color: var(--flexsuite-text, #1a202c);
    font-size: 15px;
    margin: 0 auto;
    max-width: 100%;
    background: transparent;
    padding: 8px;
    line-height: 1.5;
}

.flexchat-message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
    display: block;
}

.flexchat-input-container {
    border-top: 1px solid var(--flexsuite-border, #e2e8f0);
    background: white;
}

.flexchat-offline-message {
    padding: 15px 20px;
    text-align: center;
    color: var(--flexsuite-text-muted, #718096);
    font-size: 13px;
    background: var(--flexsuite-light-gray, #f8f9fa);
}

.flexchat-input-wrapper {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 12px;
    background: white;
    position: relative;
}

.flexchat-emoticon-toggle {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--flexsuite-border-radius, 8px);
    transition: all 0.2s;
    line-height: 1;
    flex-shrink: 0;
    color: var(--flexsuite-text-muted, #718096);
    align-self: flex-start;
}

.flexchat-emoticon-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--flexsuite-primary, #1E55B3);
}

.flexchat-emoticon-picker {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 16px;
    right: 16px;
    background: white;
    border-radius: var(--flexsuite-border-radius, 8px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
    animation: flexchat-slide-up 0.2s ease-out;
    border: 1px solid var(--flexsuite-border, #e2e8f0);
}

.flexchat-emoticon-picker::-webkit-scrollbar {
    width: 6px;
}

.flexchat-emoticon-picker::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: calc(var(--flexsuite-border-radius, 8px) * 0.375);
}

.flexchat-emoticons-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}

.flexchat-emoticon {
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--flexsuite-border-radius, 8px);
    text-align: center;
    transition: all 0.2s;
    user-select: none;
    line-height: 1;
}

.flexchat-emoticon:hover {
    background: rgba(30, 85, 179, 0.1);
    transform: scale(1.2);
}

.flexchat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.flexchat-input {
    flex: 1;
    border: 2px solid var(--flexsuite-border, #e2e8f0);
    border-radius: var(--flexsuite-border-radius, 8px);
    padding: 12px 18px;
    padding-right: 50px;
    font-family: inherit;
    font-size: 15px;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    transition: all 0.2s;
    background: #f8f9fa;
    width: 100%;
    box-sizing: border-box;
}

.flexchat-input:focus {
    outline: none;
    border-color: var(--flexsuite-primary, #1E55B3);
    background: white;
    box-shadow: 0 0 0 3px rgba(30, 85, 179, 0.1);
}

.flexchat-emoticon-inline {
    position: absolute;
    right: 12px;
    bottom: 12px;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--flexsuite-border-radius, 8px);
    transition: all 0.2s;
    color: var(--flexsuite-text-muted, #718096);
    z-index: 5;
}

.flexchat-emoticon-inline:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--flexsuite-primary, #1E55B3);
}

.flexchat-input-container {
    position: relative;
}

.flexchat-send {
    width: 100%;
    background: linear-gradient(135deg, var(--flexsuite-primary, #1E55B3) 0%, var(--flexsuite-primary-hover, #1a4a9a) 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: var(--flexsuite-border-radius, 8px);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(30, 85, 179, 0.3);
    font-size: 15px;
}

.flexchat-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(30, 85, 179, 0.4);
}

.flexchat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Typing indicator */
.flexchat-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border-radius: var(--flexsuite-border-radius, 8px);
    max-width: 200px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.flexchat-typing-text {
    font-size: 12px;
    color: var(--flexsuite-text-muted, #718096);
    font-style: italic;
}

.flexchat-typing span:not(.flexchat-typing-text) {
    width: 8px;
    height: 8px;
    background: var(--flexsuite-text-muted, #718096);
    border-radius: 50%;
    animation: flexchat-typing 1.4s infinite;
}

.flexchat-typing span:not(.flexchat-typing-text):nth-child(2) {
    animation-delay: 0.2s;
}

.flexchat-typing span:not(.flexchat-typing-text):nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes flexchat-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .flexchat-widget {
        left: 16px;
        bottom: 16px;
    }
    
    .flexchat-window {
        width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        left: 0;
    }
}

@media (max-width: 480px) {
    .flexchat-widget {
        left: 10px;
        bottom: 10px;
    }
    
    .flexchat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: calc(100% + 10px);
        left: 0;
    }
    
    .flexchat-button {
        padding: 14px 20px;
    }
    
    .flexchat-emoticons-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}
