:root {
  --dzt-primary: #ff9d00 !important;
  --dzt-primary-rgb: 113, 167, 37 !important;
  --dzt-btn-color: #71a725 !important;
}

/**
 * Dezton AI Assistant — Chat Widget Styles
 * @version 1.0.0
 */

/* ── CSS Variables (overridable via widget_color config) ── */
:root {
    --dzt-primary: #ff9d00;
    --dzt-primary-hover: #e68a00;
    --dzt-primary-light: #fff8e1;
    --dzt-btn-color: #73b31b;
    --dzt-btn-hover: #5d9116;
    --dzt-bg: #ffffff;
    --dzt-bg-secondary: #f9fafb;
    --dzt-text: #1f2937;
    --dzt-text-secondary: #6b7280;
    --dzt-border: #e5e7eb;
    --dzt-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    --dzt-radius: 16px;
    --dzt-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ── Floating Button ── */
.dzt-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--dzt-btn-color, var(--dzt-primary));
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(115, 179, 27, 0.4);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    outline: none;
}

.dzt-chat-btn:hover {
    transform: scale(1.1);
    background: var(--dzt-btn-hover, var(--dzt-primary-hover));
    box-shadow: 0 6px 28px rgba(115, 179, 27, 0.5);
}

.dzt-chat-btn.left {
    right: auto;
    left: 24px;
}

.dzt-chat-btn svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

.dzt-chat-btn.open svg.chat-icon {
    display: none;
}

.dzt-chat-btn svg.close-icon {
    display: none;
}

.dzt-chat-btn.open svg.close-icon {
    display: block;
}

/* Pulse animation on load */
.dzt-chat-btn.pulse {
    animation: dzt-pulse 2s ease-in-out 3;
}

@keyframes dzt-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(var(--dzt-primary-rgb), 0.4); }
    50% { box-shadow: 0 4px 30px rgba(var(--dzt-primary-rgb), 0.7), 0 0 0 10px rgba(var(--dzt-primary-rgb), 0.1); }
}

/* ── Chat Panel ── */
.dzt-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 420px;
    height: auto !important;
    max-height: calc(100vh - 120px);
    background: var(--dzt-bg);
    border-radius: var(--dzt-radius);
    box-shadow: var(--dzt-shadow);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: var(--dzt-font);
}

/* ── Custom Modal ── */
.dzt-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.dzt-modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}
.dzt-modal {
    background: white;
    padding: 24px;
    border-radius: 12px;
    width: 280px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.2s ease;
}
.dzt-modal-overlay.show .dzt-modal {
    transform: scale(1);
}
.dzt-modal-text {
    font-size: 14px;
    color: var(--dzt-text);
    margin-bottom: 20px;
    line-height: 1.4;
}
.dzt-modal-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.dzt-modal-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    border: none;
    font-weight: 500;
    transition: opacity 0.2s;
}
.dzt-modal-btn.confirm {
    background: var(--dzt-btn-color);
    color: white;
}
.dzt-modal-btn.cancel {
    background: #e5e7eb;
    color: #4b5563;
}
.dzt-modal-btn:hover {
    opacity: 0.9;
}

.dzt-chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.dzt-chat-panel.left {
    right: auto;
    left: 24px;
}

/* ── Header ── */
.dzt-chat-header {
    background: var(--dzt-primary);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.dzt-chat-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dzt-chat-header-avatar svg {
    width: 20px;
    height: 20px;
}

.dzt-chat-header-info {
    flex-grow: 1;
}

.dzt-chat-reset {
    margin-left: auto;
    padding: 8px;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    border-radius: 8px;
}

.dzt-chat-reset:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(45deg);
}

.dzt-chat-close {
    padding: 8px;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    border-radius: 8px;
    margin-left: 4px; /* Space between reset and close */
}

.dzt-chat-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

.dzt-chat-close svg {
    width: 20px;
    height: 20px;
}

.dzt-reset-icon {
    width: 20px;
    height: 20px;
}

.dzt-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.dzt-chat-header-status {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.dzt-chat-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34D399;
    display: inline-block;
}

/* ── Messages area ── */
.dzt-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 250px;
    max-height: 500px;
    background: var(--dzt-bg-secondary);
}

.dzt-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.dzt-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.dzt-chat-messages::-webkit-scrollbar-thumb {
    background: var(--dzt-border);
    border-radius: 2px;
}

/* ── Message bubbles ── */
.dzt-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: dzt-fadeIn 0.3s ease;
}

@keyframes dzt-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.dzt-msg.bot {
    align-self: flex-start;
    background: var(--dzt-bg);
    color: var(--dzt-text);
    border: 1px solid var(--dzt-border);
    border-bottom-left-radius: 4px;
}

.dzt-msg.user {
    align-self: flex-end;
    background: var(--dzt-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.dzt-msg.bot a {
    color: var(--dzt-primary);
    text-decoration: underline;
}

/* Typing indicator */
.dzt-msg.typing .dzt-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.dzt-msg.typing .dzt-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--dzt-text-secondary);
    animation: dzt-bounce 1.4s ease-in-out infinite;
}

.dzt-msg.typing .dzt-dots span:nth-child(2) { animation-delay: 0.2s; }
.dzt-msg.typing .dzt-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dzt-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ── Footer area ── */
/* ── Footer & Input area ── */
.dzt-chat-footer {
    padding: 16px 20px;
    background: var(--dzt-bg);
    border-top: 1px solid var(--dzt-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    padding-bottom: 24px;
}

.dzt-chat-input-wrapper {
    display: flex !important;
    gap: 12px !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
}

.dzt-chat-input {
    flex-grow: 1;
    border: 1px solid var(--dzt-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 20px;
    min-height: 44px;
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
    resize: vertical;
    max-height: 200px;
    overflow-y: hidden;
    background: var(--dzt-bg-secondary);
    color: var(--dzt-text);
    box-sizing: border-box !important;
    margin: 0 !important;
}

.dzt-chat-input:focus {
    border-color: var(--dzt-primary);
    background: var(--dzt-bg);
    box-shadow: 0 0 0 3px var(--dzt-primary-light);
}

.dzt-chat-send {
    background: var(--dzt-btn-color, var(--dzt-primary));
    color: white;
    border: none;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.dzt-chat-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.dzt-chat-send:not(:disabled):hover {
    background: var(--dzt-btn-hover, var(--dzt-primary-hover));
    transform: scale(1.05);
}

.dzt-chat-send svg {
    width: 20px;
    height: 20px;
}

.dzt-powered-by {
    text-align: center;
    font-size: 11px;
    color: var(--dzt-text-secondary);
    opacity: 0.6;
    margin-top: 8px;
    margin-bottom: 4px;
    font-weight: 500;
}

/* ============================================================
   INLINE CHAT (for /help/ page)
   ============================================================ */

.dzt-help-chat {
    width: calc(100% - 32px);
    margin: 32px auto;
    max-width: 800px;
    height: 600px !important;
    min-height: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--dzt-bg);
    border: 1px solid var(--dzt-border);
    border-radius: var(--dzt-radius);
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.dzt-inline-launcher-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 40px 0;
}

.dzt-inline-launcher {
    display: inline-flex;
    align-items: center;
    background: var(--dzt-btn-color, var(--dzt-primary));
    color: white;
    padding: 16px 32px;
    border-radius: 40px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(115, 179, 27, 0.3);
    transition: all 0.3s ease;
}

.dzt-inline-launcher:hover {
    background: var(--dzt-btn-hover, var(--dzt-primary-hover));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(115, 179, 27, 0.4);
}

.dzt-inline-launcher-icon {
    margin-right: 12px;
    display: flex;
    align-items: center;
}

.dzt-inline-launcher-icon svg {
    width: 24px;
    height: 24px;
}

/* ── Overrides for inline layout ── */
.dzt-help-chat .dzt-chat-footer {
    border-radius: 0 0 var(--dzt-radius) var(--dzt-radius);
}

.dzt-help-chat .dzt-chat-messages {
    max-height: 500px;
    min-height: 200px;
}

.dzt-help-chat .dzt-chat-header {
    border-radius: 0;
}

/* ── Quick action buttons (suggestions) ── */
.dzt-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0 4px;
}

.dzt-quick-action {
    background: var(--dzt-btn-color, var(--dzt-primary));
    color: white;
    border: 1px solid var(--dzt-btn-color, var(--dzt-primary));
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.dzt-quick-action:hover {
    background: var(--dzt-bg);
    color: var(--dzt-btn-color, var(--dzt-primary));
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .dzt-chat-panel {
        width: calc(100vw - 32px) !important;
        right: 16px !important;
        bottom: 80px !important;
        max-height: 75vh !important; /* Уменьшено ~на 20% для мобильных */
        border-radius: 12px !important;
    }

    .dzt-chat-panel.left {
        left: 8px;
    }

    .dzt-chat-btn {
        width: 52px;
        height: 52px;
        bottom: 16px;
        right: 16px;
    }

    .dzt-chat-btn.left {
        left: 16px;
    }

    .dzt-help-chat {
        margin: 12px auto !important;
        width: calc(100% - 24px) !important;
        height: 500px !important;
        max-height: 80vh !important;
    }
    
    .dzt-chat-footer {
        padding: 12px !important;
    }
}
