/* ===============================================
   Huququmvar Virtual Köməkçi — Modern Chat UI
   =============================================== */

:root {
    --hq-bg: #f4f6fb;
    --hq-surface: #ffffff;
    --hq-sidebar-bg: #0f172a;
    --hq-sidebar-hover: rgba(255, 255, 255, 0.07);
    --hq-primary: #2563eb;
    --hq-primary-dark: #1d4ed8;
    --hq-accent: #059669;
    --hq-text: #1e293b;
    --hq-text-light: #64748b;
    --hq-sidebar-text: #cbd5e1;
    --hq-border: #e2e8f0;
    --hq-radius: 14px;
    --hq-radius-sm: 10px;
    --hq-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --hq-font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

#chatContainer * {
    box-sizing: border-box;
}

.hq-app {
    position: relative;
    display: flex;
    height: calc(100vh - 120px);
    min-height: 620px;
    width: 100%;
    background: var(--hq-bg);
    font-family: var(--hq-font);
    color: var(--hq-text);
    overflow: hidden;
    border-radius: var(--hq-radius);
    box-shadow: var(--hq-shadow);
}

/* Misafir modunda sidebar tamamen gizlenir */
.hq-app.guest .hq-sidebar,
.hq-app.guest .hq-btn-menu {
    display: none !important;
}

/* ---------- Sidebar ---------- */
.hq-sidebar {
    width: 288px;
    flex-shrink: 0;
    background: var(--hq-sidebar-bg);
    display: flex;
    flex-direction: column;
    color: var(--hq-sidebar-text);
}

.hq-sidebar-head {
    padding: 18px 16px;
}

.hq-btn-new {
    width: 100%;
    padding: 12px 16px;
    background: var(--hq-primary);
    color: #fff;
    border: none;
    border-radius: var(--hq-radius-sm);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.hq-btn-new:hover {
    background: var(--hq-primary-dark);
    transform: translateY(-1px);
}

.hq-history-label {
    padding: 4px 20px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.hq-history {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hq-history::-webkit-scrollbar {
    width: 6px;
}

.hq-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.hq-history-empty {
    padding: 14px 12px;
    font-size: 0.84rem;
    color: #64748b;
    line-height: 1.5;
}

.hq-history-item {
    padding: 10px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--hq-sidebar-text);
    transition: background 0.15s ease;
}

.hq-history-item:hover {
    background: var(--hq-sidebar-hover);
}

.hq-history-item.active {
    background: rgba(37, 99, 235, 0.25);
    color: #fff;
}

.hq-history-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hq-history-del {
    opacity: 0;
    color: #f87171;
    padding: 4px 6px;
    border-radius: 5px;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.hq-history-item:hover .hq-history-del {
    opacity: 1;
}

.hq-history-del:hover {
    background: rgba(248, 113, 113, 0.15);
}

.hq-sidebar-foot {
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Main ---------- */
.hq-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--hq-bg);
}

.hq-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 22px;
    background: var(--hq-surface);
    border-bottom: 1px solid var(--hq-border);
}

.hq-btn-menu {
    display: none;
    background: transparent;
    border: 1px solid var(--hq-border);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    color: var(--hq-text);
    cursor: pointer;
}

.hq-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.hq-logo {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--hq-accent), #10b981);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.hq-title {
    font-weight: 700;
    font-size: 1.02rem;
    line-height: 1.25;
}

.hq-subtitle {
    font-size: 0.78rem;
    color: var(--hq-text-light);
}

.hq-rights {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--hq-primary);
    background: rgba(37, 99, 235, 0.09);
    border: 1px solid rgba(37, 99, 235, 0.2);
    padding: 6px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

.hq-rights:empty {
    display: none;
}

/* ---------- Messages ---------- */
.hq-messages {
    flex: 1;
    overflow-y: auto;
    padding: 26px 0 18px;
    scroll-behavior: smooth;
}

.hq-messages::-webkit-scrollbar {
    width: 8px;
}

.hq-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.hq-msg-row {
    display: flex;
    gap: 12px;
    max-width: 820px;
    margin: 0 auto 18px;
    padding: 0 24px;
    animation: hqFadeIn 0.25s ease;
}

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

.hq-msg-row.user {
    flex-direction: row-reverse;
}

.hq-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.hq-msg-row.assistant .hq-avatar {
    background: linear-gradient(135deg, var(--hq-accent), #10b981);
    color: #fff;
}

.hq-msg-row.user .hq-avatar {
    background: linear-gradient(135deg, var(--hq-primary), #6366f1);
    color: #fff;
}

.hq-bubble {
    max-width: calc(100% - 60px);
    padding: 14px 18px;
    border-radius: var(--hq-radius);
    font-size: 0.94rem;
    line-height: 1.65;
    word-wrap: break-word;
}

.hq-msg-row.assistant .hq-bubble {
    background: var(--hq-surface);
    border: 1px solid var(--hq-border);
    border-top-left-radius: 5px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.hq-msg-row.user .hq-bubble {
    background: var(--hq-primary);
    color: #fff;
    border-top-right-radius: 5px;
    white-space: pre-wrap;
}

.hq-bubble p {
    margin: 0 0 10px;
}

.hq-bubble p:last-child {
    margin-bottom: 0;
}

.hq-bubble ul {
    margin: 6px 0 10px;
    padding-left: 22px;
}

.hq-bubble li {
    margin-bottom: 5px;
}

.hq-msg-heading {
    font-weight: 700;
    font-size: 0.98rem;
    margin: 12px 0 6px;
    color: #0f172a;
}

.hq-msg-space {
    height: 6px;
}

/* ---------- Sources ---------- */
.hq-sources {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--hq-border);
}

.hq-sources-label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--hq-text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 7px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hq-source-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hq-source-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--hq-primary);
    background: rgba(37, 99, 235, 0.07);
    border: 1px solid rgba(37, 99, 235, 0.18);
    padding: 5px 11px;
    border-radius: 999px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.hq-source-chip:hover {
    background: rgba(37, 99, 235, 0.14);
    color: var(--hq-primary-dark);
}

/* ---------- Welcome ---------- */
.hq-welcome {
    max-width: 720px;
    margin: 40px auto 0;
    padding: 0 24px;
    text-align: center;
}

.hq-welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--hq-accent), #10b981);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    box-shadow: 0 8px 24px rgba(5, 150, 105, 0.25);
}

.hq-welcome h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: #0f172a;
}

.hq-welcome p {
    font-size: 0.92rem;
    color: var(--hq-text-light);
    margin: 0 0 26px;
    line-height: 1.6;
}

.hq-suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.hq-suggestion {
    text-align: left;
    padding: 14px 16px;
    background: var(--hq-surface);
    border: 1px solid var(--hq-border);
    border-radius: var(--hq-radius-sm);
    font-family: inherit;
    font-size: 0.86rem;
    color: var(--hq-text);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.hq-suggestion:hover {
    border-color: var(--hq-primary);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.hq-suggestion i {
    color: var(--hq-primary);
    margin-right: 8px;
}

/* ---------- Typing indicator ---------- */
.hq-typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 2px;
}

.hq-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: hqBounce 1.2s infinite ease-in-out;
}

.hq-typing span:nth-child(2) { animation-delay: 0.15s; }
.hq-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes hqBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.hq-typing-text {
    margin-left: 8px;
    font-size: 0.82rem;
    color: var(--hq-text-light);
}

/* ---------- Footer / Input ---------- */
.hq-footer {
    padding: 14px 24px 16px;
    background: linear-gradient(to top, var(--hq-bg) 65%, transparent);
}

.hq-input-wrap {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--hq-surface);
    border: 1px solid var(--hq-border);
    border-radius: 16px;
    padding: 10px 12px 10px 18px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hq-input-wrap:focus-within {
    border-color: var(--hq-primary);
    box-shadow: 0 2px 16px rgba(37, 99, 235, 0.15);
}

.hq-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.94rem;
    line-height: 1.5;
    color: var(--hq-text);
    max-height: 160px;
    padding: 8px 0;
}

.hq-btn-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 11px;
    background: var(--hq-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.15s ease;
}

.hq-btn-send:hover:not(:disabled) {
    background: var(--hq-primary-dark);
    transform: translateY(-1px);
}

.hq-btn-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.hq-disclaimer {
    max-width: 820px;
    margin: 9px auto 0;
    text-align: center;
    font-size: 0.74rem;
    color: #94a3b8;
}

/* ---------- Mobile ---------- */
.hq-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 90;
}

@media (max-width: 860px) {
    .hq-app {
        height: calc(100vh - 80px);
        border-radius: 0;
    }

    .hq-sidebar {
        position: absolute;
        z-index: 100;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
    }

    .hq-app.sidebar-open .hq-sidebar {
        transform: translateX(0);
    }

    .hq-app.sidebar-open .hq-overlay {
        display: block;
    }

    .hq-app:not(.guest) .hq-btn-menu {
        display: flex;
    }

    .hq-subtitle {
        display: none;
    }

    .hq-suggestions {
        grid-template-columns: 1fr;
    }

    .hq-msg-row {
        padding: 0 14px;
    }

    .hq-footer {
        padding: 10px 12px 12px;
    }
}


/* ==== Fayl əlavə etmə (yükləmə) ==== */
.hq-btn-attach {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: #eef2f7;
    color: #475569;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s;
}
.hq-btn-attach:hover { background: #e2e8f0; }
.hq-attach-bar { padding: 0 4px 8px; }
.hq-attach-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.82rem;
}
.hq-attach-remove { cursor: pointer; opacity: 0.7; }
.hq-attach-remove:hover { opacity: 1; }

/* ==== Word (.docx) düyməsi ==== */
.hq-doc-actions { margin-top: 12px; }
.hq-btn-docx {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.hq-btn-docx:hover { background: #1d4ed8; }
.hq-btn-docx:disabled { opacity: 0.6; cursor: default; }
