/* ZIP-X — sayt ichidagi AI assistent */

.zipx-root {
    --zipx-accent: #22d3ee;
    --zipx-accent2: #818cf8;
    --zipx-bg: rgba(15, 15, 20, 0.96);
    --zipx-border: rgba(129, 140, 248, 0.35);
    position: fixed;
    z-index: 9990;
    right: max(1rem, env(safe-area-inset-right));
    bottom: calc(4.5rem + env(safe-area-inset-bottom));
    font-family: inherit;
}

.page-admin .zipx-root,
.page-watch .zipx-root {
    bottom: max(1rem, env(safe-area-inset-bottom));
}

/* Player: faqat toolbar tugmasi, floating FAB yo'q */
.page-watch .zipx-root--player .zipx-fab {
    display: none !important;
}

.zipx-root--player .zipx-panel {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    bottom: auto;
    top: calc(var(--nav-height, 48px) + var(--safe-top, 0px) + 5rem);
    z-index: 250;
    max-height: min(480px, calc(100vh - var(--nav-height, 48px) - 6rem));
}

@media (min-width: 768px) {
    .page-watch .zipx-root--player {
        position: static;
    }
}

.player-zipx-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    border: 1px solid rgba(34, 211, 238, 0.35);
    background: rgba(30, 27, 75, 0.85);
    color: #22d3ee;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.player-zipx-btn img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
}

.player-zipx-btn:hover {
    border-color: #22d3ee;
    background: rgba(49, 46, 129, 0.9);
}

.zipx-clear {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem 0.35rem;
    margin-left: auto;
}

.zipx-clear:hover {
    color: #f87171;
}

.zipx-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--zipx-border);
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    box-shadow: 0 8px 32px rgba(34, 211, 238, 0.25);
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.zipx-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 40px rgba(34, 211, 238, 0.35);
}

.zipx-fab img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.zipx-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.75rem);
    width: min(380px, calc(100vw - 2rem));
    max-height: min(560px, calc(100vh - 8rem));
    display: flex;
    flex-direction: column;
    background: var(--zipx-bg);
    border: 1px solid var(--zipx-border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.zipx-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.zipx-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--zipx-border);
    background: rgba(49, 46, 129, 0.35);
}

.zipx-head img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--zipx-accent);
}

.zipx-head-text strong {
    display: block;
    font-size: 0.95rem;
    color: #fff;
}

.zipx-head-text small {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.72rem;
}

.zipx-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

.zipx-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 200px;
}

.zipx-msg {
    max-width: 92%;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.45;
    word-break: break-word;
}

.zipx-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #4338ca, #6366f1);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.zipx-msg.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.92);
    border-bottom-left-radius: 4px;
}

.zipx-msg.bot a {
    color: var(--zipx-accent);
    text-decoration: underline;
}

.zipx-cards {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.35rem;
}

.zipx-card {
    display: block;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: rgba(34, 211, 238, 0.08);
    border: 1px solid rgba(34, 211, 238, 0.2);
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.78rem;
}

.zipx-card:hover {
    background: rgba(34, 211, 238, 0.15);
}

.zipx-card strong {
    color: var(--zipx-accent);
}

.zipx-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0 0.75rem 0.5rem;
}

.zipx-starter {
    font-size: 0.72rem;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--zipx-border);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
}

.zipx-starter:hover {
    border-color: var(--zipx-accent);
    color: var(--zipx-accent);
}

.zipx-input-row {
    display: flex;
    gap: 0.4rem;
    padding: 0.65rem 0.75rem;
    border-top: 1px solid var(--zipx-border);
}

.zipx-input {
    flex: 1;
    border: 1px solid var(--zipx-border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    resize: none;
    min-height: 40px;
    max-height: 100px;
    font-family: inherit;
}

.zipx-input:focus {
    outline: none;
    border-color: var(--zipx-accent);
}

.zipx-send {
    align-self: flex-end;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--zipx-accent), var(--zipx-accent2));
    color: #0f172a;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
}

.zipx-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.zipx-typing {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    padding: 0 0.75rem 0.5rem;
}

@media (min-width: 768px) {
    .zipx-root {
        bottom: max(1.25rem, env(safe-area-inset-bottom));
    }
}
