/**
 * Gorvita Chatbot Widget - styles
 * Color palette: #009036 (Gorvita green), #ffffff, #f7f7f5
 */

#gorvita-chatbot-root {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #2c2c2c;
}

/* === FLOATING BUBBLE === */
.gvc-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #009036;
    box-shadow: 0 4px 16px rgba(0, 144, 54, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
}

.gvc-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 144, 54, 0.45);
}

.gvc-bubble svg {
    width: 28px;
    height: 28px;
    fill: #fff;
}

.gvc-bubble.is-hidden {
    display: none;
}

.gvc-bubble-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #009036;
    opacity: 0.4;
    animation: gvc-pulse 2s ease-out infinite;
}

@keyframes gvc-pulse {
    0% { transform: scale(1); opacity: 0.4; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* === CHAT PANEL === */
.gvc-panel {
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: gvc-slide-up 0.25s ease-out;
}

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

.gvc-panel.is-hidden {
    display: none;
}

/* === HEADER === */
.gvc-header {
    background: linear-gradient(135deg, #009036 0%, #00a83f 100%);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.gvc-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
}

.gvc-header-text strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.gvc-header-text small {
    display: block;
    font-size: 12px;
    opacity: 0.9;
}

.gvc-status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

.gvc-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.gvc-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.gvc-close svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* === MESSAGES === */
.gvc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: #f7f7f5;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gvc-messages::-webkit-scrollbar {
    width: 6px;
}

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

.gvc-messages::-webkit-scrollbar-thumb {
    background: #d4d4d0;
    border-radius: 3px;
}

.gvc-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    animation: gvc-fade-in 0.2s ease-out;
}

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

.gvc-message-bot {
    align-self: flex-start;
    background: #fff;
    color: #2c2c2c;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.gvc-message-user {
    align-self: flex-end;
    background: #009036;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.gvc-message a {
    color: #009036;
    text-decoration: underline;
    word-break: break-word;
}

.gvc-message-user a {
    color: #fff;
}

.gvc-message ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.gvc-message li {
    margin: 4px 0;
}

.gvc-message p {
    margin: 0 0 8px;
}

.gvc-message p:last-child {
    margin-bottom: 0;
}

/* === TYPING INDICATOR === */
.gvc-typing {
    align-self: flex-start;
    background: #fff;
    padding: 14px 16px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 4px;
}

.gvc-typing span {
    width: 7px;
    height: 7px;
    background: #009036;
    border-radius: 50%;
    opacity: 0.4;
    animation: gvc-typing-bounce 1.4s ease-in-out infinite;
}

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

@keyframes gvc-typing-bounce {
    0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* === INPUT === */
.gvc-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #ececec;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.gvc-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e0e0db;
    border-radius: 22px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    background: #f7f7f5;
    color: #2c2c2c;
}

.gvc-input:focus {
    border-color: #009036;
    background: #fff;
}

.gvc-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #009036;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.gvc-send:hover:not(:disabled) {
    background: #007a2e;
}

.gvc-send:active:not(:disabled) {
    transform: scale(0.95);
}

.gvc-send:disabled {
    background: #c5c5bf;
    cursor: not-allowed;
}

.gvc-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* === FOOTER === */
.gvc-footer {
    text-align: center;
    padding: 7px 12px;
    background: #f7f7f5;
    font-size: 10.5px;
    color: #9a9a95;
    border-top: 0.5px solid #ececec;
    letter-spacing: 0.2px;
    line-height: 1.3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.gvc-footer-icon {
    width: 10px;
    height: 10px;
    opacity: 0.55;
    flex-shrink: 0;
}

.gvc-footer a {
    color: #009036;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

.gvc-footer a:hover {
    color: #007a2e;
    text-decoration: underline;
}

.gvc-footer.is-hidden {
    display: none;
}

/* === RESPONSIVE === */

/* Tablet - lekko większy panel zeby wykorzystac miejsce */
@media (min-width: 481px) and (max-width: 768px) {
    .gvc-panel {
        width: 420px;
        height: 640px;
    }
}

/* Mobile - full screen z safe area + klawiatura-friendly */
@media (max-width: 640px) {
    #gorvita-chatbot-root {
        bottom: max(16px, env(safe-area-inset-bottom, 16px));
        right: max(16px, env(safe-area-inset-right, 16px));
    }

    .gvc-bubble {
        /* Tap target wciaz 60px - dobry standard */
        width: 60px;
        height: 60px;
    }

    .gvc-panel {
        /* Full screen z marginesem zachowujacym safe area */
        position: fixed;
        bottom: max(16px, env(safe-area-inset-bottom, 16px));
        right: max(16px, env(safe-area-inset-right, 16px));
        left: max(16px, env(safe-area-inset-left, 16px));
        top: max(16px, env(safe-area-inset-top, 16px));
        width: auto;
        /* dvh = dynamic viewport height, automatycznie skraca przy klawiaturze
           Fallback na vh dla starszych przegladarek */
        height: auto;
        max-height: none;
        border-radius: 12px;
    }

    /* iOS Safari nie zoom-uje przy tap jezeli input ma font-size >= 16px */
    .gvc-input {
        font-size: 16px;
    }

    /* Mniejszy panel header na mobile - oszczedza miejsce w pionie */
    .gvc-header {
        padding: 14px 16px;
    }

    .gvc-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* Bardzo male telefony (320px - stary iPhone SE) - zmniejsz bubble */
@media (max-width: 360px) {
    .gvc-bubble {
        width: 56px;
        height: 56px;
    }

    .gvc-bubble svg {
        width: 26px;
        height: 26px;
    }
}

/* Landscape mobile - krotki ekran, panel niech bedzie scrollable */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
    .gvc-panel {
        position: fixed;
        bottom: 8px;
        right: 8px;
        left: 8px;
        top: 8px;
        width: auto;
        height: auto;
        border-radius: 8px;
    }
}
