/**
 * DrukPlus Hybrid Chat Widget — Styles
 */

/* Hide legacy floating contact button on pages where chat-widget is active */
#contact-float-btn {
    display: none !important;
}

/* 1. Floating Trigger Button */
.druk-chat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    background: linear-gradient(135deg, #ff6b1a 0%, #ff8833 100%);
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 14px 22px;
    font-family: 'Onest', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(255, 107, 26, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.druk-chat-trigger.hidden-open {
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.85);
}

.druk-chat-trigger:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 30px rgba(255, 107, 26, 0.55);
}

.druk-chat-trigger.hidden-open:hover {
    transform: translateY(12px) scale(0.85);
}

.druk-chat-trigger:active {
    transform: translateY(0) scale(0.98);
}

.druk-chat-trigger-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.druk-chat-trigger-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.druk-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    background: #e63946;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: none;
    animation: drukPulse 2s infinite;
}

.druk-chat-badge.active {
    display: block;
}

@keyframes drukPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(230, 57, 70, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(230, 57, 70, 0); }
}

/* 2. Main Chat Window */
.druk-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    width: 440px;
    max-width: calc(100vw - 32px);
    height: min(560px, calc(100dvh - 120px));
    max-height: calc(100vh - 48px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Onest', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.druk-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* 3. Header */
.druk-chat-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    user-select: none;
}

.druk-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.druk-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ff6b1a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255, 107, 26, 0.4);
}

.druk-chat-avatar img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.druk-chat-title-group {
    display: flex;
    flex-direction: column;
}

.druk-chat-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
}

.druk-chat-subtitle {
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.druk-chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
}

.druk-chat-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.druk-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* 4. Messages Body */
.druk-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.druk-chat-body::-webkit-scrollbar {
    width: 5px;
}

.druk-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Message Item */
.druk-msg {
    max-width: 82%;
    display: flex;
    flex-direction: column;
    animation: drukMsgSlide 0.25s ease-out;
}

@keyframes drukMsgSlide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.druk-msg-user {
    align-self: flex-end;
}

.druk-msg-assistant,
.druk-msg-operator {
    align-self: flex-start;
}

.druk-msg-system {
    align-self: center;
    max-width: 90%;
    margin: 4px 0;
}

.druk-msg-bubble {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

/* User Bubble */
.druk-msg-user .druk-msg-bubble {
    background: linear-gradient(135deg, #2676bb 0%, #1d5f96 100%);
    color: #ffffff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 2px 8px rgba(38, 118, 187, 0.25);
}

/* Assistant Bubble */
.druk-msg-assistant .druk-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

/* Operator Bubble */
.druk-msg-operator .druk-msg-bubble {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
    border-left: 3px solid #0284c7;
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.08);
}

.druk-msg-operator-author {
    font-size: 11px;
    font-weight: 700;
    color: #0284c7;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* System Pill */
.druk-msg-system .druk-msg-bubble {
    background: #e2e8f0;
    color: #475569;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    text-align: center;
    box-shadow: none;
}

/* Status Banner Notice */
.druk-chat-notice-banner {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    background: #f1f5f9;
    color: #475569;
    border-top: 1px solid #e2e8f0;
    display: none;
}

.druk-chat-notice-banner.active {
    display: block;
}

/* 5. Footer Input Form */
.druk-chat-footer {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.druk-chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: #0f172a;
    resize: none;
    max-height: 100px;
    min-height: 42px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8fafc;
}

.druk-chat-input:focus {
    border-color: #ff6b1a;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 107, 26, 0.15);
}

.druk-chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #ff6b1a;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s, opacity 0.2s;
}

.druk-chat-send-btn:hover {
    background: #e0550b;
}

.druk-chat-send-btn:active {
    transform: scale(0.94);
}

.druk-chat-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.druk-chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* New Session Button inside Closed Notice */
.druk-new-session-btn {
    display: inline-block;
    margin-top: 6px;
    padding: 6px 14px;
    background: #ff6b1a;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.druk-new-session-btn:hover {
    background: #e0550b;
}

/* Channel Selection Box inside Notice Banner */
.druk-channel-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
    padding: 4px 0;
}

.druk-channel-box.compact {
    gap: 6px;
}

.druk-channel-text {
    font-size: 12px;
    line-height: 1.4;
    color: #334155;
}

.druk-channel-subtext {
    display: block;
    color: #64748b;
    font-size: 11px;
    margin-top: 2px;
}

.druk-channel-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.druk-channel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
    user-select: none;
}

.druk-channel-btn.sm {
    padding: 4px 12px;
    font-size: 12px;
}

.druk-channel-btn:hover {
    transform: translateY(-1px);
    opacity: 0.94;
}

.druk-btn-tg {
    background: #0088cc;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0, 136, 204, 0.25);
}

.druk-btn-viber {
    background: #7360f2;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(115, 96, 242, 0.25);
}

/* Viber Form Inline */
.druk-viber-form {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 10px 12px;
    margin-top: 6px;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.druk-viber-label {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
}

.druk-viber-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
}

.druk-viber-prefix {
    background: #e2e8f0;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 10px;
    user-select: none;
    border-right: 1px solid #cbd5e1;
}

.druk-viber-phone {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    outline: none;
}

.druk-viber-error {
    color: #e11d48;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}

.druk-viber-submit {
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    background: #7360f2;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.druk-viber-submit:hover {
    background: #5f4cdb;
}

.druk-viber-submit:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.druk-viber-success {
    margin-top: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 8px 12px;
    border-radius: 8px;
}

/* 6. Mobile Responsiveness & Safe Area */
@media (max-width: 480px) {
    .druk-chat-trigger {
        bottom: 16px;
        right: 16px;
        padding: 12px 18px;
        font-size: 14px;
    }

    .druk-chat-window {
        bottom: 16px;
        right: 16px;
        left: 16px;
        width: auto;
        max-width: none;
        height: min(600px, calc(100dvh - 32px));
        max-height: calc(100vh - 32px);
        border-radius: 16px;
        margin-bottom: env(safe-area-inset-bottom, 0px);
    }
}
