/**
 * Herkules AI - Poradca na detaile kurzu
 * Štýly pre trigger, bublinu, modal a chat
 *
 * @since 1.2.0
 */

/* ========================================
   SCHOVAŤ SMARTSUPP NA DETAILE KURZU
   ======================================== */
#smartsupp-widget-container {
    display: none !important;
}

/* Body lock pri otvorenom modali */
body.herkules-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ========================================
   CHAT WIDGET (vpravo dole)
   ======================================== */
#herkules-detail-trigger {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9998;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #179CFA;
    border-radius: 28px;
    padding: 10px 18px 10px 12px;
    box-shadow: 0 4px 16px rgba(23, 156, 250, 0.35);
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.2s ease;
}

#herkules-detail-trigger:hover {
    box-shadow: 0 6px 24px rgba(23, 156, 250, 0.5);
    transform: translateY(-2px);
}

#herkules-detail-trigger.herkules-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#herkules-detail-trigger.herkules-hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* Ikona chatu v kruhu */
.herkules-trigger-icon {
    width: 36px;
    height: 36px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Text */
.herkules-trigger-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.herkules-trigger-text span:first-child {
    color: #ffffff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    font-weight: 700;
}

.herkules-trigger-text span:last-child {
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 12px;
    font-weight: 400;
}

/* Zelená online bodka - skrytá, funkciu plní zelená ikona */
.herkules-online-dot {
    display: none;
}

/* ========================================
   BUBLINKA nad triggerom
   ======================================== */
#herkules-bubble {
    position: fixed;
    right: 20px;
    bottom: 85px;
    z-index: 9999;
    background: #f0f7ff;
    border: 1px solid #d0e3f5;
    border-radius: 14px;
    padding: 14px 38px 14px 16px;
    max-width: 280px;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

#herkules-bubble.herkules-bubble-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#herkules-bubble-text {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: #2c3e50;
}

#herkules-bubble-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    padding: 0;
    line-height: 1;
}

#herkules-bubble-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Šípka smerujúca dole na trigger */
.herkules-bubble-arrow {
    position: absolute;
    bottom: -8px;
    right: 30px;
    width: 16px;
    height: 16px;
    background: #f0f7ff;
    border-right: 1px solid #d0e3f5;
    border-bottom: 1px solid #d0e3f5;
    transform: rotate(45deg);
    box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.06);
}

/* ========================================
   MOBILE - len zelená ikona chatu
   ======================================== */
@media (max-width: 768px) {
    #herkules-detail-trigger {
        right: 5px !important;
        bottom: 20px !important;
        padding: 0 !important;
        background: #22c55e !important;
        border-radius: 50% !important;
        width: 52px !important;
        height: 52px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border: 3px solid #ffffff !important;
        box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4) !important;
        animation: herkules-pulse-mobile 2s ease-in-out infinite;
        gap: 0 !important;
    }

    #herkules-detail-trigger:hover {
        transform: none;
    }

    .herkules-trigger-text,
    .herkules-online-dot {
        display: none;
    }

    .herkules-trigger-icon {
        width: auto;
        height: auto;
        background: none !important;
        border: none !important;
    }

    .herkules-trigger-icon svg {
        width: 28px !important;
        height: 28px !important;
    }

    /* Bublinka - mobile pozícia */
    #herkules-bubble {
        right: 5px;
        bottom: 80px;
        max-width: 240px;
    }

    .herkules-bubble-arrow {
        right: 20px;
    }

    @keyframes herkules-pulse-mobile {
        0%, 100% { box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4); }
        50% { box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4), 0 0 0 8px rgba(34, 197, 94, 0.15); }
    }
}

/* ========================================
   MODAL - FULLSCREEN CHAT
   ======================================== */
#herkules-detail-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    z-index: 10000;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#herkules-detail-overlay.herkules-visible {
    opacity: 1;
}

#herkules-detail-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 700px;
    height: 85vh;
    max-height: 700px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-radius: 20px;
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: fixed;
}

#herkules-detail-modal.herkules-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Modal close button */
.herkules-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #f0f2f5;
    border: none;
    color: #7f8c8d;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    z-index: 2;
}

.herkules-modal-close:hover {
    background: #e0e3e8;
    color: #2c3e50;
}

/* Modal body */
.herkules-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

/* ========================================
   KROK 1 - ÚVODNÁ OBRAZOVKA
   ======================================== */
#herkules-step-suhlas {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 24px;
    padding: 10px 0 20px 0;
}

#herkules-step-suhlas .herkules-chat-disclaimer {
    margin-top: auto;
}

/* Horná časť - nadpis + popis */
.herkules-intro-top {
    text-align: center;
}

.herkules-intro-top h3 {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 24px;
    color: #2c3e50;
    margin: 0 0 8px 0;
    font-weight: 700;
}

.herkules-intro-top p {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #5a6c7d;
    margin: 0;
}

/* Čiara */
.herkules-intro-divider {
    width: 100%;
    height: 1px;
    background: #e8edf2;
}

/* Bloky - obrázok + obsah */
.herkules-intro-block {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f2f5;
}

.herkules-intro-block:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.herkules-intro-block-img {
    width: 35%;
    max-width: 140px;
    height: auto;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.herkules-intro-block-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.herkules-intro-block-content h4 {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

/* Kontakt buttony */
.herkules-contact-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.herkules-contact-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #f0f7ff;
    border: 1px solid #d0e3f7;
    border-radius: 8px;
    color: #179CFA;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.herkules-contact-btn:hover {
    background: #e0efff;
    border-color: #179CFA;
}

.herkules-contact-btn-email {
    background: #f0faf0;
    border-color: #c3e6cb;
    color: #28a745;
}

.herkules-contact-btn-email:hover {
    background: #e0f5e0;
    border-color: #28a745;
}

/* Online status */
.herkules-status-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 12px;
    color: #5a6c7d;
    margin-top: 2px;
}

.herkules-dot-green {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    animation: herkules-dot-pulse 2s ease-in-out infinite;
}

.herkules-dot-gray {
    width: 8px;
    height: 8px;
    background: #adb5bd;
    border-radius: 50%;
    flex-shrink: 0;
}

@keyframes herkules-dot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0); }
}

/* Mobile - bloky pod seba */
@media (max-width: 480px) {
    .herkules-intro-block {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .herkules-intro-block-img {
        width: 50%;
        max-width: 120px;
    }

    .herkules-intro-block-content {
        align-items: center;
    }

    .herkules-contact-buttons {
        align-items: stretch;
        width: 100%;
    }
}

#herkules-btn-suhlas {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

#herkules-btn-suhlas:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

/* ========================================
   KROK 2 - CHAT
   ======================================== */
#herkules-step-chat {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#herkules-step-chat.herkules-active {
    display: flex;
}

/* Chat správy */
#herkules-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.herkules-msg {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: herkules-msg-in 0.3s ease;
}

@keyframes herkules-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.herkules-msg-ai {
    align-self: flex-start;
}

.herkules-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.herkules-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.herkules-msg-user .herkules-msg-avatar {
    background: #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.herkules-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.herkules-msg-ai .herkules-msg-bubble {
    background: #f0f2f5;
    color: #2c3e50;
    border-bottom-left-radius: 4px;
}

.herkules-msg-ai .herkules-msg-bubble a {
    color: #2980b9;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.herkules-msg-ai .herkules-msg-bubble a:hover {
    color: #1a5276;
}

.herkules-msg-user .herkules-msg-bubble {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.herkules-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.herkules-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aab;
    animation: herkules-typing-dot 1.4s infinite ease-in-out;
}

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

@keyframes herkules-typing-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Chat input */
.herkules-chat-input-wrap {
    display: flex;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid #eef1f5;
    margin-top: 12px;
    flex-shrink: 0;
}

#herkules-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e5ec;
    border-radius: 50px;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

#herkules-chat-input:focus {
    border-color: #3498db;
}

#herkules-chat-input::placeholder {
    color: #aab4c0;
}

#herkules-chat-send {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
}

#herkules-chat-send:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
}

#herkules-chat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Disclaimer pod chatom */
.herkules-chat-disclaimer {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 10px;
    line-height: 1.3;
    color: #b0b8c1;
    text-align: center;
    margin: 6px 0 0 0;
    padding: 0;
    flex-shrink: 0;
}

.herkules-chat-disclaimer a {
    color: #b0b8c1;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.herkules-chat-disclaimer a:hover {
    color: #7f8c8d;
}

/* ========================================
   DEBUG BADGE
   ======================================== */
#herkules-debug-badge {
    position: fixed;
    top: 40px;
    right: 10px;
    background: #e74c3c;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    z-index: 10002;
    opacity: 0.8;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    #herkules-detail-trigger {
        right: 0px;
        bottom: 10px;
    }

    /* Modal - fullscreen na mobile */
    #herkules-detail-modal {
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        overflow: hidden;
    }

    #herkules-detail-modal.herkules-visible {
        transform: translateY(0);
    }

    /* Overlay tiež fullscreen */
    #herkules-detail-overlay {
        backdrop-filter: none;
    }

    .herkules-modal-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 22px;
    }

    .herkules-modal-body {
        padding: 16px;
    }

    /* Úvodná obrazovka */
    #herkules-step-suhlas {
        padding: 10px;
        gap: 16px;
    }

    #herkules-step-suhlas h2 {
        font-size: 20px;
    }

    .herkules-intro-avatar {
        width: 80px;
    }

    /* Chat - input vždy viditeľný */
    .herkules-chat-input-wrap {
        padding-top: 12px;
        margin-top: 8px;
    }

    #herkules-chat-input {
        padding: 14px 16px;
        font-size: 16px;
    }

    #herkules-chat-send {
        width: 48px;
        height: 48px;
    }
}

/* ========================================
   ACTION MESSAGE (čo Herkules robí - tool call indikátor)
   ======================================== */
.herkules-msg-bubble.herkules-msg-action {
    font-style: italic;
    color: #555;
    background: #f0f6ff !important;
}

.herkules-msg-bubble.herkules-msg-action .herkules-action-text {
    opacity: 0.85;
}

.herkules-msg-bubble.herkules-msg-action .herkules-action-dots {
    display: inline-block;
    width: 24px;
    text-align: left;
    color: #2271b1;
    font-weight: 700;
}

/* ========================================
   PROVOKUJÚCA BUBLINKA (nad triggerom)
   ======================================== */
.hwc-bubble {
    position: fixed;
    right: 20px;
    bottom: 90px;            /* nad triggerom */
    z-index: 9999;
    max-width: 280px;
    background: #ffffff;
    border-radius: 16px;
    padding: 14px 36px 14px 16px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: #1d2327;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.hwc-bubble.hwc-bubble-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    animation: hwcBubblePulse 2s ease-out 0.3s 2;
}

@keyframes hwcBubblePulse {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Hrot bubliny smerujúci k triggeru */
.hwc-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 30px;
    width: 16px;
    height: 16px;
    background: #ffffff;
    transform: rotate(45deg);
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.05);
    z-index: -1;
}

.hwc-bubble-text {
    cursor: pointer;
    font-weight: 500;
}

.hwc-bubble-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: #555;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.hwc-bubble-close:hover {
    background: rgba(0, 0, 0, 0.12);
}

@media (max-width: 768px) {
    .hwc-bubble {
        display: none !important;
    }
}

/* ========================================
   QUICK REPLY CHIPY (pod welcome správou v chate)
   ======================================== */
.hwc-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 12px 56px;     /* odsadenie aby boli zarovnané s AI bubblami */
    animation: hwcChipsFadeIn 0.4s ease-out;
}

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

.hwc-chip {
    display: inline-block;
    padding: 5px 11px;
    background: #ffffff;
    border: 1px solid #179CFA;
    border-radius: 14px;
    color: #179CFA;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    line-height: 1.3;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.hwc-chip:hover {
    background: #179CFA;
    color: #ffffff;
    transform: translateY(-1px);
}

.hwc-chip:active {
    transform: translateY(0);
}

/* Mobile - ešte menšie chipy aby sa zmestilo viac vedľa seba */
@media (max-width: 768px) {
    .hwc-quick-chips {
        gap: 5px;
        margin-left: 48px;
    }
    .hwc-chip {
        padding: 4px 9px;
        font-size: 11px;
        border-radius: 12px;
    }
    .hwc-quick-hint {
        margin-left: 48px;
        font-size: 11px;
    }
}

/* ========================================
   QUICK HINT - "alebo napíšte vašu otázku" + šípka dole
   ======================================== */
.hwc-quick-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 16px 56px;     /* zarovnané s chipmi */
    color: #888;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;
    font-style: italic;
    animation: hwcChipsFadeIn 0.5s ease-out 0.1s both;
}

.hwc-quick-hint-text {
    line-height: 1.4;
}

.hwc-quick-hint-arrow {
    display: inline-flex;
    align-items: center;
    color: #179CFA;
    animation: hwcArrowPulse 1.6s ease-in-out infinite;
}

@keyframes hwcArrowPulse {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    50% {
        transform: translateY(4px);
        opacity: 1;
    }
}
