/* ==========================================================================
   AUTOKLASEN CHAT WIDGET - CSS
   Version: 1.0.0
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Variables
   -------------------------------------------------------------------------- */
:root {
    --ak-primary: #e94560;
    --ak-primary-dark: #d63050;
    --ak-secondary: #1a1a2e;
    --ak-secondary-light: #16213e;
    --ak-text: #333333;
    --ak-text-light: #666666;
    --ak-text-white: #ffffff;
    --ak-bg-light: #f8f9fa;
    --ak-bg-white: #ffffff;
    --ak-border: #e0e0e0;
    --ak-shadow: rgba(0, 0, 0, 0.15);
    --ak-shadow-strong: rgba(0, 0, 0, 0.25);
    --ak-success: #28a745;
    --ak-ai-bg: #f0f2f5;
    --ak-visitor-bg: #e94560;
    --ak-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --ak-radius: 12px;
    --ak-radius-sm: 8px;
    --ak-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   Container Principal
   -------------------------------------------------------------------------- */
#ak-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: var(--ak-font);
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

#ak-chat-widget *,
#ak-chat-widget *::before,
#ak-chat-widget *::after {
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Buton Minimizat (Floating Action Button)
   -------------------------------------------------------------------------- */
.ak-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ak-primary) 0%, var(--ak-primary-dark) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--ak-shadow-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ak-transition);
    position: relative;
    overflow: hidden;
}

.ak-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px var(--ak-shadow-strong);
}

.ak-chat-button:active {
    transform: scale(1.05);
}

.ak-chat-button svg {
    width: 28px;
    height: 28px;
    fill: var(--ak-text-white);
    transition: transform var(--ak-transition);
}

.ak-chat-button.ak-has-unread::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: var(--ak-success);
    border-radius: 50%;
    border: 2px solid var(--ak-text-white);
    animation: ak-pulse 2s infinite;
}

@keyframes ak-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* Badge pentru conversație activă */
.ak-chat-button .ak-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--ak-success);
    color: var(--ak-text-white);
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid var(--ak-text-white);
}

/* --------------------------------------------------------------------------
   Fereastra Chat
   -------------------------------------------------------------------------- */
.ak-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 370px;
    height: 520px;
    max-height: calc(100vh - 100px);
    background: var(--ak-bg-white);
    border-radius: var(--ak-radius);
    box-shadow: 0 10px 40px var(--ak-shadow-strong);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all var(--ak-transition);
}

.ak-chat-window.ak-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.ak-chat-header {
    background: linear-gradient(135deg, var(--ak-secondary) 0%, var(--ak-secondary-light) 100%);
    color: var(--ak-text-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.ak-chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ak-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
    position: relative;
}

.ak-chat-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--ak-success);
    border-radius: 50%;
    border: 2px solid var(--ak-secondary);
}

.ak-chat-info {
    flex: 1;
    min-width: 0;
}

.ak-chat-name {
    font-weight: 600;
    font-size: 16px;
    margin: 0 0 2px 0;
}

.ak-chat-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ak-chat-status .ak-typing-indicator {
    display: none;
}

.ak-chat-status.ak-typing .ak-status-text {
    display: none;
}

.ak-chat-status.ak-typing .ak-typing-indicator {
    display: flex;
    align-items: center;
    gap: 3px;
}

.ak-typing-indicator span {
    width: 4px;
    height: 4px;
    background: var(--ak-text-white);
    border-radius: 50%;
    animation: ak-typing 1.4s infinite ease-in-out;
}

.ak-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.ak-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.ak-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ak-typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

.ak-chat-minimize {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ak-transition);
}

.ak-chat-minimize:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ak-chat-minimize svg {
    width: 18px;
    height: 18px;
    fill: var(--ak-text-white);
}

/* --------------------------------------------------------------------------
   Zona Mesaje
   -------------------------------------------------------------------------- */
.ak-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--ak-bg-light);
}

/* Scrollbar personalizat */
.ak-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.ak-chat-messages::-webkit-scrollbar-thumb {
    background: var(--ak-border);
    border-radius: 3px;
}

.ak-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--ak-text-light);
}

/* --------------------------------------------------------------------------
   Mesaje
   -------------------------------------------------------------------------- */
.ak-message {
    max-width: 85%;
    animation: ak-message-in 0.3s ease-out;
}

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

.ak-message-content {
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.ak-message-time {
    font-size: 10px;
    color: var(--ak-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

/* Mesaje AI / Operator */
.ak-message.ak-message-ai,
.ak-message.ak-message-operator {
    align-self: flex-start;
}

.ak-message.ak-message-ai .ak-message-content,
.ak-message.ak-message-operator .ak-message-content {
    background: var(--ak-bg-white);
    color: var(--ak-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.ak-message.ak-message-operator .ak-message-content {
    border-left: 3px solid var(--ak-primary);
}

/* Mesaje Vizitator */
.ak-message.ak-message-visitor {
    align-self: flex-end;
}

.ak-message.ak-message-visitor .ak-message-content {
    background: var(--ak-visitor-bg);
    color: var(--ak-text-white);
    border-bottom-right-radius: 4px;
}

.ak-message.ak-message-visitor .ak-message-time {
    text-align: right;
}

/* Mesaj Bun Venit / Trigger */
.ak-message.ak-message-welcome {
    align-self: center;
    max-width: 90%;
}

.ak-message.ak-message-welcome .ak-message-content {
    background: var(--ak-bg-white);
    color: var(--ak-text);
    text-align: center;
    border-radius: var(--ak-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 14px 20px;
}

/* Sender Label pentru operator */
.ak-message-sender {
    font-size: 11px;
    font-weight: 600;
    color: var(--ak-primary);
    margin-bottom: 4px;
    padding: 0 4px;
}

/* --------------------------------------------------------------------------
   Input Area
   -------------------------------------------------------------------------- */
.ak-chat-input-area {
    padding: 12px 16px;
    background: var(--ak-bg-white);
    border-top: 1px solid var(--ak-border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}

.ak-chat-input-wrapper {
    flex: 1;
    position: relative;
}

.ak-chat-input {
    width: 100%;
    border: 1px solid var(--ak-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-family: var(--ak-font);
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color var(--ak-transition), box-shadow var(--ak-transition);
    line-height: 1.4;
}

.ak-chat-input:focus {
    border-color: var(--ak-primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}

.ak-chat-input::placeholder {
    color: var(--ak-text-light);
}

.ak-chat-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--ak-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--ak-transition);
    flex-shrink: 0;
}

.ak-chat-send:hover:not(:disabled) {
    background: var(--ak-primary-dark);
    transform: scale(1.05);
}

.ak-chat-send:disabled {
    background: var(--ak-border);
    cursor: not-allowed;
}

.ak-chat-send svg {
    width: 20px;
    height: 20px;
    fill: var(--ak-text-white);
    margin-left: 2px;
}

/* --------------------------------------------------------------------------
   Footer / Powered By
   -------------------------------------------------------------------------- */
.ak-chat-footer {
    padding: 8px 16px;
    background: var(--ak-bg-light);
    text-align: center;
    font-size: 11px;
    color: var(--ak-text-light);
    border-top: 1px solid var(--ak-border);
    flex-shrink: 0;
}

.ak-chat-footer a {
    color: var(--ak-primary);
    text-decoration: none;
    font-weight: 500;
}

.ak-chat-footer a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Stare: Conversație închisă
   -------------------------------------------------------------------------- */
.ak-chat-closed-notice {
    padding: 12px 16px;
    background: var(--ak-bg-light);
    text-align: center;
    color: var(--ak-text-light);
    font-size: 13px;
    border-top: 1px solid var(--ak-border);
}

.ak-chat-input-area.ak-disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Responsive - Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    #ak-chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .ak-chat-button {
        width: 56px;
        height: 56px;
    }

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

    .ak-chat-window.ak-open {
        transform: translateY(0);
    }

    .ak-chat-header {
        padding: 14px 16px;
        border-radius: 0;
    }

    .ak-chat-minimize {
        width: 36px;
        height: 36px;
    }
}

/* --------------------------------------------------------------------------
   Animații Extra
   -------------------------------------------------------------------------- */
.ak-shake {
    animation: ak-shake 0.5s ease-in-out;
}

@keyframes ak-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* Efect de pulsare pentru buton când e trigger activ */
.ak-chat-button.ak-attention {
    animation: ak-attention 1.5s ease-in-out infinite;
}

@keyframes ak-attention {
    0%, 100% { 
        box-shadow: 0 4px 20px var(--ak-shadow-strong);
    }
    50% { 
        box-shadow: 0 4px 20px var(--ak-shadow-strong), 0 0 0 8px rgba(233, 69, 96, 0.25);
    }
}

/* --------------------------------------------------------------------------
   Print - Ascunde widget-ul
   -------------------------------------------------------------------------- */
@media print {
    #ak-chat-widget {
        display: none !important;
    }
}
