/**
 * VodaBG ChatBot - Frontend Styles v2.6
 * 
 * Customizable via CSS variables (set in PHP wp_add_inline_style):
 * --vodabg-primary, --vodabg-secondary
 */

:root {
    --vodabg-primary: #1a73e8;
    --vodabg-secondary: #0d47a1;
}

.vodabg-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ============================================ */
/* LAUNCHER BUTTON + PULSE ANIMATION            */
/* ============================================ */
.vodabg-chatbot-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--vodabg-primary) 0%, var(--vodabg-secondary) 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(26, 115, 232, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    position: relative;
    animation: vodabg-chatbot-bounce-in 0.5s ease;
}

/* Pulse ring animation */
.vodabg-chatbot-launcher::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: var(--vodabg-primary);
    opacity: 0.4;
    animation: vodabg-chatbot-pulse 2s infinite;
    z-index: -1;
}

.vodabg-chatbot-launcher:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(26, 115, 232, 0.5);
}

.vodabg-chatbot-launcher:hover::before {
    animation-play-state: paused;
}

@keyframes vodabg-chatbot-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    70% {
        transform: scale(1.4);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

.vodabg-chatbot-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    padding: 0 5px;
    z-index: 1;
}

@keyframes vodabg-chatbot-bounce-in {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* ============================================ */
/* CHAT WINDOW                                  */
/* ============================================ */
.vodabg-chatbot-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: vodabg-chatbot-slide-up 0.3s ease;
}

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

/* ============================================ */
/* HEADER                                       */
/* ============================================ */
.vodabg-chatbot-header {
    background: linear-gradient(135deg, var(--vodabg-primary) 0%, var(--vodabg-secondary) 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.vodabg-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vodabg-chatbot-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
}

.vodabg-chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.vodabg-chatbot-header-title {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
}

.vodabg-chatbot-header-status {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.vodabg-chatbot-status-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.vodabg-chatbot-header-actions {
    display: flex;
    gap: 4px;
}

.vodabg-chatbot-header-actions button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.vodabg-chatbot-header-actions button:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ============================================ */
/* PRE-CHAT FORM                                */
/* ============================================ */
.vodabg-chatbot-prechat {
    padding: 22px 18px;
    flex: 1;
    overflow-y: auto;
}

.vodabg-chatbot-welcome-text {
    color: #444;
    margin: 0 0 18px 0;
    font-size: 14px;
    line-height: 1.5;
}

.vodabg-chatbot-prechat-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vodabg-chatbot-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.vodabg-chatbot-field input[type="text"] {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid #e1e4e8;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.vodabg-chatbot-field input[type="text"]:focus {
    outline: none;
    border-color: var(--vodabg-primary);
}

/* Real-time validation states */
.vodabg-chatbot-field input.vodabg-chatbot-input-valid {
    border-color: #00a32a;
    background: #f0fdf4;
}

.vodabg-chatbot-field input.vodabg-chatbot-input-invalid {
    border-color: #d63638;
    background: #fef2f2;
}

/* Hint text under input */
.vodabg-chatbot-hint {
    display: block;
    font-size: 11px;
    color: #666;
    margin-top: 5px;
    line-height: 1.4;
    transition: color 0.2s;
}

.vodabg-chatbot-hint.vodabg-chatbot-hint-valid {
    color: #00a32a;
    font-weight: 600;
}

.vodabg-chatbot-hint.vodabg-chatbot-hint-invalid {
    color: #d63638;
    font-weight: 600;
}

.vodabg-chatbot-field-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #444;
    cursor: pointer;
    font-weight: normal;
}

.vodabg-chatbot-field-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.vodabg-chatbot-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    border-left: 3px solid #ef4444;
}

.vodabg-chatbot-btn-primary {
    background: linear-gradient(135deg, var(--vodabg-primary) 0%, var(--vodabg-secondary) 100%);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.vodabg-chatbot-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

.vodabg-chatbot-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.vodabg-chatbot-privacy-note {
    font-size: 11px;
    color: #888;
    text-align: center;
    margin: 6px 0 0 0;
    line-height: 1.4;
}

.vodabg-chatbot-privacy-note a {
    color: var(--vodabg-primary);
    text-decoration: none;
}

/* ============================================ */
/* CHAT BODY + MESSAGES                         */
/* ============================================ */
.vodabg-chatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f6f8fa;
}

.vodabg-chatbot-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vodabg-chatbot-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    animation: vodabg-chatbot-fade-in 0.3s;
}

@keyframes vodabg-chatbot-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.vodabg-chatbot-msg-bot {
    background: #fff;
    color: #222;
    border-radius: 14px 14px 14px 4px;
    align-self: flex-start;
    border: 1px solid #e1e4e8;
}

.vodabg-chatbot-msg-user {
    background: linear-gradient(135deg, var(--vodabg-primary) 0%, var(--vodabg-secondary) 100%);
    color: #fff;
    border-radius: 14px 14px 4px 14px;
    align-self: flex-end;
}

.vodabg-chatbot-msg-system {
    background: transparent;
    color: #888;
    font-style: italic;
    font-size: 12px;
    text-align: center;
    align-self: center;
    padding: 4px 10px;
}

/* === RESUME / RETURNING USER === */

/* Hint в pre-chat: "Здравейте отново, ..." */
.vodabg-chatbot-returning-hint {
    background: linear-gradient(135deg, #fff8ec 0%, #fef3c7 100%);
    border: 1px solid #f59e0b;
    color: #92400e;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 13px;
    line-height: 1.5;
    animation: vodabg-chatbot-fade-in 0.5s;
}

.vodabg-chatbot-returning-hint strong {
    color: #78350f;
}

.vodabg-chatbot-clear-stored {
    color: #92400e;
    text-decoration: underline;
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.7;
}

.vodabg-chatbot-clear-stored:hover {
    opacity: 1;
    color: #78350f;
}

/* History separator в chat */
.vodabg-chatbot-history-separator {
    position: relative;
    text-align: center;
    margin: 16px 0 12px 0;
    padding: 0;
}

.vodabg-chatbot-history-separator::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #d4d8df, transparent);
    z-index: 0;
}

.vodabg-chatbot-history-separator span {
    position: relative;
    z-index: 1;
    background: #f6f8fa;
    padding: 4px 12px;
    font-size: 11px;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 12px;
}

/* History messages (визуално различни от новите) */
.vodabg-chatbot-msg-history {
    opacity: 0.7;
    filter: saturate(0.7);
}

.vodabg-chatbot-msg-history.vodabg-chatbot-msg-user {
    background: rgba(26, 115, 232, 0.7) !important;
}
.vodabg-chatbot-msg-plain {
    align-self: stretch;
    background: #fef9ef;
    color: #555;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.55;
    text-align: center;
    border-radius: 8px;
    border: 1px dashed #f59e0b;
    margin: 8px 0;
    animation: vodabg-chatbot-fade-in 0.4s;
}

/* Typing indicator */
.vodabg-chatbot-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 14px 14px 14px 4px;
}

.vodabg-chatbot-typing span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: vodabg-chatbot-typing-bounce 1.4s infinite;
}

.vodabg-chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.vodabg-chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes vodabg-chatbot-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================ */
/* SUGGESTIONS ACCORDION                        */
/* ============================================ */
.vodabg-chatbot-suggestions {
    margin-top: 12px;
    padding-top: 0;
    border-top: 1px solid #e1e4e8;
}

.vodabg-chatbot-suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid #e1e4e8;
    transition: all 0.2s;
}

.vodabg-chatbot-suggestions-header:hover {
    background: #f0f4ff;
    border-color: var(--vodabg-primary);
}

.vodabg-chatbot-suggestions-header-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--vodabg-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.vodabg-chatbot-suggestions-toggle {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.vodabg-chatbot-suggestions-content {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.vodabg-chatbot-suggestions-content.collapsed {
    max-height: 0 !important;
}

.vodabg-chatbot-suggestions-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 4px;
}

/* COMPACT suggestion buttons */
.vodabg-chatbot-suggestion {
    background: #fff;
    border: 1px solid #d4d8df;
    color: #333;
    padding: 6px 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    text-align: left;
    line-height: 1.3;
}

.vodabg-chatbot-suggestion:hover {
    background: var(--vodabg-primary);
    color: #fff;
    border-color: var(--vodabg-primary);
    transform: translateX(2px);
}

/* Анимация при клик */
.vodabg-chatbot-suggestion-clicked {
    background: var(--vodabg-primary) !important;
    color: #fff !important;
    transform: scale(0.92) !important;
    pointer-events: none;
    transition: all 0.15s ease-out !important;
}

/* Exhausted state */
.vodabg-chatbot-exhausted {
    color: #888 !important;
    font-style: italic;
    text-align: center;
    padding: 10px;
    background: #fafafa;
    border-radius: 6px;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-size: 12px;
}

/* ============================================ */
/* INPUT AREA                                   */
/* ============================================ */
.vodabg-chatbot-input-area {
    border-top: 1px solid #e1e4e8;
    padding: 10px 12px;
    background: #fff;
    flex-shrink: 0;
}

.vodabg-chatbot-message-form {
    display: flex;
    gap: 8px;
}

#vodabg-chatbot-message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e1e4e8;
    border-radius: 22px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

#vodabg-chatbot-message-input:focus {
    border-color: var(--vodabg-primary);
}

.vodabg-chatbot-btn-send {
    background: linear-gradient(135deg, var(--vodabg-primary) 0%, var(--vodabg-secondary) 100%);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
    flex-shrink: 0;
}

.vodabg-chatbot-btn-send:hover {
    transform: scale(1.05);
}

.vodabg-chatbot-btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.vodabg-chatbot-quick-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.vodabg-chatbot-btn-link {
    background: transparent;
    border: none;
    color: var(--vodabg-primary);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 6px;
    font-family: inherit;
    text-decoration: underline;
}

.vodabg-chatbot-btn-link:hover {
    color: var(--vodabg-secondary);
}

#vodabg-chatbot-human-btn {
    font-weight: 700;
}

/* ============================================ */
/* AUTOCOMPLETE                                 */
/* ============================================ */
.vodabg-chatbot-autocomplete {
    background: #f6f8fa;
    border: 1px solid #d4d8df;
    border-radius: 10px 10px 0 0;
    padding: 8px;
    margin: -1px -1px 8px -1px;
    max-height: 180px;
    overflow-y: auto;
    animation: vodabg-chatbot-fade-in 0.2s;
}

.vodabg-chatbot-autocomplete-label {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    padding: 2px 4px 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.vodabg-chatbot-autocomplete-item {
    display: block;
    width: 100%;
    background: #fff;
    border: 1px solid #e1e4e8;
    color: #222;
    padding: 8px 11px;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    margin-bottom: 3px;
    transition: all 0.15s;
}

.vodabg-chatbot-autocomplete-item:last-child {
    margin-bottom: 0;
}

.vodabg-chatbot-autocomplete-item:hover {
    background: var(--vodabg-primary);
    color: #fff;
    border-color: var(--vodabg-primary);
    transform: translateX(2px);
}

.vodabg-chatbot-autocomplete-icon {
    color: var(--vodabg-primary);
    font-weight: 700;
    margin-right: 4px;
}

.vodabg-chatbot-autocomplete-item:hover .vodabg-chatbot-autocomplete-icon {
    color: #fff;
}

/* ============================================ */
/* FOOTER                                       */
/* ============================================ */
.vodabg-chatbot-footer {
    background: #f6f8fa;
    padding: 6px 16px;
    border-top: 1px solid #e1e4e8;
    text-align: center;
    color: #888;
    font-size: 10px;
    flex-shrink: 0;
}

/* ============================================ */
/* MOBILE RESPONSIVE                            */
/* ============================================ */
@media (max-width: 480px) {
    .vodabg-chatbot-container {
        bottom: 10px;
        right: 10px;
    }
    
    .vodabg-chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 20px);
        bottom: 10px;
        right: 10px;
        border-radius: 12px;
    }
    
    .vodabg-chatbot-launcher {
        width: 56px;
        height: 56px;
    }
}
