/* ==========================================================================
   Whisper CSS — extracted from chat-popout.html
   All whisper-related styles: container, badges, windows, messages,
   input, GIF/emote pickers, color menu, resize handles, overflow menu,
   drag & drop, scrollbar styles, animations, and mobile overrides.
   ========================================================================== */

/* --- Scrollbar styles for whisper elements --- */
.whisper-messages::-webkit-scrollbar,
.whisper-gif-grid::-webkit-scrollbar,
.whisper-emote-content::-webkit-scrollbar { width: 10px; }

.whisper-messages::-webkit-scrollbar-track,
.whisper-gif-grid::-webkit-scrollbar-track,
.whisper-emote-content::-webkit-scrollbar-track { background: #1e293b; border-radius: 5px; margin: 4px 0; }

.whisper-messages::-webkit-scrollbar-thumb,
.whisper-gif-grid::-webkit-scrollbar-thumb,
.whisper-emote-content::-webkit-scrollbar-thumb { background: #334155; border: 2px solid #1e293b; border-radius: 5px; }

.whisper-messages::-webkit-scrollbar-thumb:hover,
.whisper-gif-grid::-webkit-scrollbar-thumb:hover,
.whisper-emote-content::-webkit-scrollbar-thumb:hover { background: #475569; }

.whisper-messages,
.whisper-gif-grid,
.whisper-emote-content { scrollbar-width: thin; scrollbar-color: #334155 #1e293b; }

/* 10.05.2026: WhisperSystem bubliny natvrdo skryte (uzivatel chce kompletni odstraneni
   po pridani whisper tabu + badge). Container zustava v DOM pro WhisperSystem.init()
   ale display:none ho zneviditelni. */
.whisper-container { display: none !important; }

/* --- Container --- */
.whisper-container-original-placeholder {
    position: fixed;
    top: 48px;
    right: 8px;
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    gap: 6px;
    z-index: 100;
    pointer-events: none;
    max-width: calc(100vw - 16px);
}
.whisper-container > * {
    pointer-events: auto;
}

/* --- Badge --- */
.whisper-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #10b981;
    color: #1a1a2e;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, transform 0.1s;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Mobile drag: zadne browser gestures, primy touch→drag bez 300ms delay */
    touch-action: none;
}
.whisper-badge:hover { background: #34d399; transform: translateY(-1px); }
.whisper-badge-count {
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 0 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    line-height: 16px;
}
.whisper-badge-close { font-size: 10px; opacity: 0.6; margin-left: 2px; cursor: pointer; }
.whisper-badge-close:hover { opacity: 1; }

/* --- Window --- */
.whisper-window {
    width: 280px;
    background: #1e1e2e;
    border: 1px solid rgba(16,185,129,0.3);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    overflow: hidden;
    resize: none;
    min-width: 220px;
    min-height: 180px;
    max-height: 80vh;
    position: relative;
}

/* --- Resize handles --- */
.ww-resize {
    position: absolute;
    z-index: 5;
}
.ww-resize-n { top: -3px; left: 8px; right: 8px; height: 6px; cursor: n-resize; }
.ww-resize-s { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: s-resize; }
.ww-resize-w { left: -3px; top: 8px; bottom: 8px; width: 6px; cursor: w-resize; }
.ww-resize-e { right: -3px; top: 8px; bottom: 8px; width: 6px; cursor: e-resize; }
.ww-resize-nw { top: -3px; left: -3px; width: 10px; height: 10px; cursor: nw-resize; }
.ww-resize-ne { top: -3px; right: -3px; width: 10px; height: 10px; cursor: ne-resize; }
.ww-resize-sw { bottom: -3px; left: -3px; width: 10px; height: 10px; cursor: sw-resize; }
.ww-resize-se { bottom: -3px; right: -3px; width: 10px; height: 10px; cursor: se-resize; }

/* --- Window header --- */
.whisper-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #10b981;
    color: #1a1a2e;
    font-size: 12px;
    font-weight: 600;
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
}
.whisper-window-header-actions { display: flex; gap: 6px; }
.whisper-window-header-btn {
    background: none; border: none; color: #1a1a2e;
    cursor: pointer; font-size: 12px; padding: 0 2px; opacity: 0.7;
}
.whisper-window-header-btn:hover { opacity: 1; }

/* --- Messages --- */
.whisper-messages {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 80px;
    font-size: 13px;
}
.whisper-msg {
    font-size: inherit;
    line-height: 1.4;
    padding: 3px 6px;
    border-radius: 6px;
    max-width: 90%;
    word-break: break-word;
    overflow: hidden;
    flex-shrink: 0;
}
.whisper-msg-in {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
    align-self: flex-start;
}
.whisper-msg-out {
    background: rgba(16,185,129,0.15);
    color: #34d399;
    align-self: flex-end;
}
.whisper-msg-sender { font-size: 9px; font-weight: 600; margin-bottom: 1px; }
.whisper-msg-in .whisper-msg-sender { color: #a78bfa; }
.whisper-msg-out .whisper-msg-sender { color: #34d399; }
.whisper-msg-time { font-size: 9px; color: #6b7280; margin-top: 1px; }
.whisper-msg-read { font-size: 9px; color: #34d399; margin-left: 4px; }

/* --- Media (images, audio) --- */
.whisper-media { margin: 4px 0 2px; overflow: hidden; clear: both; }
.whisper-media-img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    cursor: pointer;
    object-fit: contain;
    display: block;
    width: auto;
    height: auto;
    min-height: 40px;
    background: rgba(255,255,255,0.03);
}
.whisper-msg .chat-emote {
    height: 24px;
    vertical-align: middle;
    margin: 0 1px;
}

/* --- Input area --- */
.whisper-input-area {
    display: flex;
    flex-direction: column;
    padding: 4px 6px;
    gap: 3px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.whisper-input {
    flex: 1;
    min-width: 0;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(16,185,129,0.2);
    border-radius: 4px;
    color: #e2e8f0;
    font-size: 12px;
    padding: 4px 8px;
    outline: none;
    font-family: inherit;
}
.whisper-input:focus { border-color: #10b981; }
.whisper-send-btn {
    background: #10b981; border: none; color: #1a1a2e;
    border-radius: 4px; padding: 4px 10px;
    font-size: 12px; font-weight: 600; cursor: pointer;
}
.whisper-send-btn:hover { background: #34d399; }

/* --- Media buttons --- */
.whisper-media-btn {
    background: rgba(255,255,255,0.08); border: none; color: #94a3b8;
    border-radius: 4px; padding: 4px 6px;
    font-size: 11px; cursor: pointer; flex-shrink: 0;
}
.whisper-media-btn:hover { background: rgba(255,255,255,0.15); color: #e2e8f0; }
.whisper-media-btn.recording { background: rgba(239,68,68,0.3); color: #ef4444; animation: whisperRecPulse 1s ease-in-out infinite; }
@keyframes whisperRecPulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

/* --- Audio player --- */
.whisper-audio { display: inline-flex; align-items: center; gap: 5px; background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2); border-radius: 12px; padding: 3px 8px; margin: 3px 0; }
.whisper-audio-play { background: none; border: none; color: #10b981; cursor: pointer; font-size: 13px; padding: 0; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.whisper-audio-play:hover { color: #34d399; }
.whisper-audio-progress { width: 50px; height: 3px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.whisper-audio-progress-bar { height: 100%; background: #10b981; border-radius: 2px; width: 0%; transition: width 0.1s linear; }
.whisper-audio-duration { font-size: 9px; color: #9ca3af; min-width: 22px; }

/* --- GIF picker --- */
.whisper-gif-picker {
    width: 100%;
    background: #1e1e2e; border: 1px solid rgba(168,85,247,0.3);
    border-radius: 0 0 8px 8px; max-height: 250px; overflow: hidden;
    display: flex; flex-direction: column; z-index: 10;
    margin-top: -1px;
}
.whisper-gif-search {
    background: rgba(255,255,255,0.05); border: none; border-bottom: 1px solid rgba(255,255,255,0.06);
    color: #e2e8f0; font-size: 12px; padding: 6px 8px; outline: none;
    font-family: inherit; flex-shrink: 0;
}
.whisper-gif-search::placeholder { color: #6b7280; }
.whisper-gif-grid {
    display: flex; flex-wrap: wrap; gap: 4px;
    align-content: flex-start;
    padding: 4px; overflow-y: auto; flex: 1;
    min-height: 0;
}
.whisper-gif-item {
    width: calc(50% - 2px); flex-shrink: 0;
    cursor: pointer; border-radius: 4px; overflow: hidden;
    background: rgba(255,255,255,0.03);
}
.whisper-gif-item img {
    width: 100%; height: auto; display: block; border-radius: 4px;
    transition: opacity 0.15s;
}
.whisper-gif-item:hover img { opacity: 0.8; }

/* --- GIF picker fullscreen on mobile --- */
@media (max-width: 600px) {
    .whisper-gif-picker {
        position: fixed !important;
        inset: 0 !important;
        width: 100% !important;
        max-height: none !important;
        height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
        margin: 0 !important;
        z-index: 9999 !important;
        background: rgba(15,20,35,0.98);
        backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    }
    .whisper-gif-picker .whisper-gif-search {
        font-size: 16px;
        padding: 12px 14px;
        border-bottom: 1px solid rgba(168,85,247,0.2);
    }
    .whisper-gif-picker .whisper-gif-grid {
        gap: 6px;
        padding: 8px;
        -webkit-overflow-scrolling: touch;
    }
    .whisper-gif-picker .whisper-gif-item {
        width: calc(50% - 3px);
        border-radius: 8px;
    }
    .whisper-gif-picker .whisper-gif-item img {
        border-radius: 8px;
    }
}

/* --- Emote picker --- */
.whisper-emote-picker {
    width: 100%;
    background: #1e1e2e; border: 1px solid rgba(168,85,247,0.3);
    border-radius: 0 0 8px 8px; max-height: 280px; overflow: hidden;
    display: flex; flex-direction: column; z-index: 10;
    margin-top: -1px;
}
.whisper-emote-search {
    background: rgba(255,255,255,0.05); border: none; border-bottom: 1px solid rgba(255,255,255,0.06);
    color: #e2e8f0; font-size: 12px; padding: 6px 8px; outline: none;
    font-family: inherit; flex-shrink: 0; width: 100%; box-sizing: border-box;
}
.whisper-emote-search::placeholder { color: #6b7280; }
.whisper-emote-content {
    overflow-y: auto; flex: 1; min-height: 0; padding: 4px;
}
.whisper-emote-group { color: #9ca3af; font-size: 10px; font-weight: 600; padding: 4px 2px 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.whisper-emote-grid {
    display: flex; flex-wrap: wrap; gap: 2px;
}
.whisper-emote-item {
    width: 32px; height: 32px; cursor: pointer; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.whisper-emote-item:hover { background: rgba(168,85,247,0.2); }
.whisper-emote-item img { max-width: 28px; max-height: 28px; display: block; }

/* --- Twitch button --- */
.whisper-twitch-btn { transition: background 0.2s; }
.whisper-twitch-btn:hover { opacity: 0.85; }

/* --- Animations --- */
@keyframes whisperPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
    50% { box-shadow: 0 0 8px 4px rgba(16,185,129,0.3); }
}
.whisper-badge.new-message { animation: whisperPulse 1s ease-in-out 3; }

/* --- Color menu --- */
.whisper-color-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: #1e1e2e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 10002;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    min-width: 220px;
}
.whisper-color-menu-label { font-size: 9px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; }
.whisper-color-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.whisper-color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.15s;
}
.whisper-color-dot:hover { transform: scale(1.2); }
.whisper-color-dot.active { border-color: #fff; }
.whisper-bg-row { display: flex; align-items: center; gap: 6px; }
.whisper-bg-color-pick { width: 28px; height: 22px; border: 1px solid rgba(255,255,255,0.15); border-radius: 4px; cursor: pointer; background: none; padding: 0; }
.whisper-bg-slider { flex: 1; height: 4px; accent-color: #a78bfa; cursor: pointer; min-width: 60px; }
.whisper-bg-slider-val { font-size: 9px; color: #9ca3af; min-width: 28px; text-align: right; font-family: monospace; }
.whisper-bg-input { width: 100%; background: #2d2a3e; border: 1px solid rgba(255,255,255,0.1); border-radius: 4px; padding: 3px 6px; color: #e2e8f0; font-size: 10px; outline: none; font-family: inherit; }
.whisper-bg-input:focus { border-color: rgba(168,85,247,0.5); }
.whisper-bg-img-row { display: flex; gap: 4px; align-items: center; width: 100%; }
.whisper-bg-img-row .whisper-bg-input { flex: 1; min-width: 0; }
.whisper-bg-upload-btn { background: rgba(168,85,247,0.2); border: 1px solid rgba(168,85,247,0.3); border-radius: 4px; color: #c4b5fd; font-size: 10px; padding: 3px 6px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.whisper-bg-upload-btn:hover { background: rgba(168,85,247,0.35); }
.whisper-bg-reset { background: none; border: 1px solid rgba(255,255,255,0.1); border-radius: 4px; color: #6b7280; font-size: 9px; padding: 2px 8px; cursor: pointer; align-self: flex-end; }
.whisper-bg-reset:hover { color: #e2e8f0; border-color: rgba(255,255,255,0.25); }

/* --- Overflow menu --- */
.whisper-overflow-btn {
    display: inline-flex;
    align-items: center;
    background: #374151;
    color: #d1d5db;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    position: relative;
}
.whisper-overflow-btn:hover { background: #4b5563; }
.whisper-overflow-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #1e1e2e;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 120px;
    z-index: 10003;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.whisper-overflow-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #d1d5db;
    white-space: nowrap;
}
.whisper-overflow-item:hover { background: rgba(255,255,255,0.1); }
.whisper-overflow-item .overflow-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.whisper-overflow-item .overflow-count {
    background: #dc2626; color: #fff; font-size: 9px; padding: 0 4px;
    border-radius: 8px; margin-left: auto;
}

/* --- Window wrapper drag & drop --- */
.whisper-window-wrapper.dragged {
    position: fixed !important;
    z-index: 201;
    transition: none;
}
.whisper-window-wrapper.dragging {
    opacity: 0.9;
    cursor: grabbing;
    /* Compositor-layer promotion — vyhne se paintu/reflow pri kazdem frame dragu.
       Drag pouziva transform: translate3d(...) ktery se vykresluje na GPU. */
    will-change: transform;
    transition: none;
    /* Badge ma pointer-events: none na dragged child? Ne — wrapper je drag target. */
}
.whisper-window-wrapper.dragging .whisper-window-header {
    cursor: grabbing;
}
/* Zabran prechodum / animacim bojovat s transform dragu */
.whisper-window-wrapper.dragging * {
    transition: none !important;
    animation-play-state: paused !important;
}

/* --- Mobile overrides (max-width: 768px) --- */
@media (max-width: 768px) {
    .whisper-container {
        position: fixed;
        top: 36px;
        bottom: auto;
        left: 0;
        right: 0;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        padding: 4px 6px;
        z-index: 200;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .whisper-window-wrapper {
        flex-shrink: 0;
    }
    .whisper-window-wrapper.dragged {
        position: fixed !important;
    }
    .whisper-badge {
        border-radius: 12px;
        padding: 4px 10px;
        font-size: 12px;
    }
    .whisper-window {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        height: 55dvh;
        max-height: 60dvh;
        border-radius: 12px 12px 0 0;
        border-bottom: none;
        resize: none;
    }
    .whisper-messages {
        max-height: 45dvh;
        min-height: 120px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .whisper-input {
        font-size: 16px;
        padding: 8px 10px;
    }
    .whisper-input-area {
        padding: 6px 8px;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
        gap: 6px;
    }
    .whisper-send-btn {
        padding: 8px 14px;
        font-size: 14px;
    }
    .whisper-window-header {
        padding: 8px 12px;
        font-size: 14px;
    }
    .whisper-window-header-btn {
        font-size: 16px;
        padding: 2px 6px;
    }
}

/* === 25.05.2026: AUTO-OPEN flash animace pri prichozim whisperu ===
 * Pridano kdyz user dostane novy whisper a okno se automaticky otevre,
 * aby bylo jasne ze prislo neco noveho. Pulse 2.5s cycle.
 */
@keyframes whisper-new-flash-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.7); }
    50%  { box-shadow: 0 0 0 12px rgba(168, 85, 247, 0); transform: scale(1.015); }
    100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); transform: scale(1); }
}
.whisper-new-flash {
    animation: whisper-new-flash-pulse 0.9s ease-out 2 !important;
    transition: box-shadow 0.3s, transform 0.3s;
}
.whisper-new-flash .whisper-window-header {
    background: linear-gradient(90deg, rgba(168, 85, 247, 0.35), rgba(168, 85, 247, 0.15)) !important;
    transition: background 0.4s;
}

/* === 25.05.2026: PERSISTENT pulse na okno s neprectenou zpravou ===
 * Pulsuje DOKUD user neklikne dovnitr — pak se zruzi + marks as read.
 */
@keyframes whisper-pending-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.7), 0 0 20px rgba(168, 85, 247, 0.3); }
    50%      { box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.4), 0 0 30px rgba(168, 85, 247, 0.5); }
}
.whisper-pending-read {
    animation: whisper-pending-pulse 1.4s ease-in-out infinite !important;
    border-radius: 12px;
}
.whisper-pending-read .whisper-window-header {
    background: linear-gradient(90deg, rgba(168, 85, 247, 0.45), rgba(168, 85, 247, 0.20)) !important;
}
.whisper-pending-read .whisper-window-header > span::before {
    content: '🔴 ';
    margin-right: 4px;
    animation: whisper-pending-pulse 1s ease-in-out infinite;
}
