/**
 * Holos AI - Unified Input Capsule Stylesheet
 * Single-line minimal pill design + 4-mode cycle + popup checklist + dynamic right controls
 */

/* ── Container Wrapper ── */
.holos-capsule-wrapper {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    position: relative;
    user-select: none;
}

/* ── Capsule Main Box ── */
.holos-capsule-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--bg-secondary, #FFFFFF);
    border: 1px solid var(--border-subtle, #E8E5DD) !important;
    border-radius: 32px;
    min-height: 58px;
    padding: 8px 12px 8px 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.02);
    position: relative;
    transition: box-shadow 0.2s ease, border-radius 0.2s ease;
    outline: none !important;
    box-sizing: border-box;
}

/* Strict requirement: Border color NEVER changes when clicked/focused */
.holos-capsule-bar:focus-within,
.holos-capsule-bar:hover,
.holos-capsule-bar:active {
    border-color: var(--border-subtle, #E8E5DD) !important;
    outline: none !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
}

/* ── Attachment Preview Container ── */
.holos-capsule-attachments {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 4px 2px 4px;
    margin-bottom: 4px;
    background: transparent;
    border: none;
    width: 100%;
    box-sizing: border-box;
    animation: fadeIn 0.15s ease-out;
}
.holos-capsule-attachments.has-items { display: flex; }

.holos-attachment-card {
    position: relative;
    width: 54px;
    height: 54px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.holos-attachment-card.is-doc {
    width: auto;
    min-width: 100px;
    max-width: 180px;
    height: 46px;
    padding: 0 10px 0 8px;
    border-radius: 10px;
    background: var(--bg-elevated, #F4F2EB);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.holos-attachment-card.is-doc .doc-icon { font-size: 22px; color: var(--primary-accent, #FF9933); }
.holos-attachment-card.is-doc .doc-info { display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.holos-attachment-card.is-doc .doc-name { font-size: 0.78rem; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.holos-attachment-card.is-doc .doc-meta { font-size: 0.68rem; color: var(--text-muted); }

.holos-attachment-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.holos-attachment-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease, transform 0.15s ease;
    z-index: 2;
}
.holos-attachment-remove:hover { background: rgba(239, 68, 68, 0.9); transform: scale(1.1); }
.holos-attachment-remove .material-symbols-outlined { font-size: 13px !important; line-height: 1; color: #FFFFFF; }

.holos-capsule-row {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 40px;
    transition: all 0.18s ease;
}

/* When multiline expands: Full-width text area on top, actions toolbar at bottom */
.holos-capsule-bar.is-multiline { border-radius: 20px; padding: 10px 12px 8px 12px; }
.holos-capsule-bar.is-multiline .holos-capsule-row { flex-wrap: wrap; align-items: center; justify-content: space-between; }
.holos-capsule-bar.is-multiline .holos-capsule-center { order: 1; flex: 0 0 100%; width: 100%; padding: 0 2px 8px 2px; }
.holos-capsule-bar.is-multiline .holos-capsule-textarea { width: 100%; max-height: 240px; line-height: 1.5; }
.holos-capsule-bar.is-multiline .holos-capsule-left { order: 2; margin-left: -2px; }
.holos-capsule-bar.is-multiline .holos-capsule-right { order: 3; margin-left: auto; margin-right: -2px; }

/* ── Left Function Button Wrapper & Popup ── */
.holos-capsule-left {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Single Cycle Button */
.holos-mode-cycle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-primary, #1C1B1F);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.holos-mode-cycle-btn:hover {
    background: var(--bg-elevated, #F4F2EB);
}

.holos-mode-cycle-btn:active {
    transform: scale(0.94);
}

.holos-mode-cycle-btn .material-symbols-outlined {
    font-size: 20px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ── Custom 4-Mode Popup Menu (Screenshot Match) ── */
.holos-mode-popup-menu {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    z-index: 1000;
    background: var(--bg-secondary, #FFFFFF);
    border: 1px solid var(--border-subtle, #E8E5DD);
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04);
    min-width: 175px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(0.98);
    transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s ease;
    pointer-events: none;
}

/* Open via .is-open class on click */
.holos-mode-popup-menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Popup Menu Item */
.holos-mode-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    outline: none;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.holos-mode-item:hover {
    background: var(--bg-elevated, #F4F2EB);
}

.holos-mode-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.holos-mode-item-left .material-symbols-outlined {
    font-size: 19px;
    color: var(--text-primary, #1C1B1F);
}

.holos-mode-item-label {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary, #1C1B1F);
    letter-spacing: -0.01em;
}

.holos-mode-item-check {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary, #1C1B1F);
}

.holos-mode-item-check .material-symbols-outlined {
    font-size: 19px;
    font-weight: 600;
    opacity: 1;
    transition: opacity 0.15s ease;
}

.holos-mode-item:not(.is-checked) .holos-mode-item-check .material-symbols-outlined {
    opacity: 0;
}

.holos-mode-item.is-active-running .holos-mode-item-label {
    font-weight: 600;
}

/* ── Center Input Textarea ── */
.holos-capsule-center {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 0 8px 0 6px;
}

.holos-capsule-textarea {
    width: 100%;
    height: 24px;
    min-height: 24px;
    max-height: 200px;
    border: none !important;
    background: transparent !important;
    outline: none !important;
    resize: none;
    font-family: inherit;
    font-size: 0.96rem;
    line-height: 24px;
    color: var(--text-primary, #1C1B1F);
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    overflow-y: hidden;
    user-select: text;
}

.holos-capsule-textarea::placeholder {
    color: var(--text-muted, #79747E);
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

.holos-capsule-textarea:focus::placeholder {
    opacity: 0.55;
}

/* ── Right Actions ── */
.holos-capsule-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Standard Icon Button (+ / Add) */
.holos-btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary, #49454F);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.holos-btn-icon:hover {
    background: var(--bg-elevated, #F2F1EC);
    color: var(--text-primary, #1C1B1F);
}

.holos-btn-icon .material-symbols-outlined {
    font-size: 23px;
    font-weight: 300 !important;
}

/* Language Toggle Icon / Text (Transparent, no background, icon or EN) */
.holos-lang-toggle-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary, #49454F);
    font-size: 0.85rem;
    font-weight: 450;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    outline: none;
    letter-spacing: 0.02em;
    -webkit-tap-highlight-color: transparent;
}

.holos-lang-toggle-btn:hover {
    background: var(--bg-elevated, #F2F1EC);
    color: var(--text-primary, #1C1B1F);
}

.holos-lang-toggle-btn.is-en {
    background: transparent;
    color: var(--text-primary, #1C1B1F);
    border: none;
    font-weight: 500;
}

.holos-lang-toggle-btn .material-symbols-outlined {
    font-size: 21px;
}

.holos-lang-en-text {
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
}

/* Multi-Function Action Button (Mic / Send / Stop) */
.holos-btn-action {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-primary, #1C1B1F);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.18s ease;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.holos-btn-action:hover {
    background: var(--bg-elevated, #F4F2EB);
}

/* Active Send Button (Filled dark circle with white arrow) */
.holos-btn-action.state-send {
    background: var(--text-primary, #1C1B1F);
    color: var(--bg-primary, #FAF8F5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.holos-btn-action.state-send:hover {
    opacity: 0.9;
    transform: scale(1.04);
}

/* Stop Button (Generating) */
.holos-btn-action.state-stop {
    background: var(--text-primary, #1C1B1F);
    color: var(--bg-primary, #FAF8F5);
    animation: holos-pulse 1.8s infinite ease-in-out;
}

.holos-btn-action.state-stop:hover {
    opacity: 0.9;
}

.holos-btn-action .material-symbols-outlined {
    font-size: 20px;
    font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.holos-btn-action.state-send .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}

@keyframes holos-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

/* ── Responsive Adaptation ── */
@media (max-width: 640px) {
    .holos-capsule-wrapper {
        max-width: 100%;
        padding: 0 4px;
    }
    .holos-capsule-bar {
        min-height: 58px;
        border-radius: 29px;
        padding: 6px 10px 6px 8px;
    }
    .holos-mode-cycle-btn {
        width: 36px;
        height: 36px;
    }
    .holos-btn-action {
        width: 36px;
        height: 36px;
    }
    .holos-capsule-textarea {
        font-size: 0.92rem;
    }
}

/* ── Unauthenticated Capsule State ── */
.holos-capsule-wrapper.capsule-unauth .holos-capsule-bar {
    cursor: pointer;
    background: var(--bg-elevated);
}
.holos-capsule-wrapper.capsule-unauth .holos-capsule-textarea {
    cursor: pointer;
}
.holos-capsule-wrapper.capsule-unauth .holos-btn-action {
    cursor: pointer;
}
