/* ============================================
   HATWIN — Feature Modules (login, voice, dock, workspace)
   ============================================ */

/* ===== 登录弹窗 ===== */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-modal h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 8px;
}
.login-modal p {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 20px;
}
.login-modal input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--muted-2);
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 12px;
    box-sizing: border-box;
}
.login-modal input:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(26,54,93,0.1);
}
.login-modal .btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--navy);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
}
.login-modal .btn-primary:hover { background: rgba(26,54,93,0.9); }
.login-modal .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.login-modal .switch-link {
    text-align: center;
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--muted);
}
.login-modal .switch-link a {
    color: var(--navy);
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
}
.login-modal .error-msg {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: -4px;
    margin-bottom: 8px;
}
.chat-count-hint {
    font-size: 0.75rem;
    color: var(--muted-2);
    text-align: center;
    margin-top: 4px;
}
.chat-count-hint.warning { color: var(--gold); }

/* ===== 录音浮层面板 ===== */
.voice-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: 45%;
    bottom: 0;
    max-width: 430px;
    margin: 0 auto;
    background: radial-gradient(ellipse 120% 80% at 50% 90%, #5b6ed8 0%, #5050c0 25%, #4a3dba 50%, #3d2d9a 75%, #2d1d7a 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 45;
    border-radius: 24px 24px 0 0;
}
.voice-panel.hidden { display: none !important; }

.voice-cancel-arc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
}
.voice-cancel-arc.visible {
    opacity: 1;
    transform: translateY(-8px);
}
.voice-cancel-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 1px;
}
.voice-panel-hint {
    color: rgba(255, 255, 255, 0.85);
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 2px;
    margin: 0;
}
.voice-wave-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 24px;
}
.voice-wave-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.45);
    animation: voiceWave 1.1s ease-in-out infinite;
}
.voice-wave-dots span:nth-child(5),
.voice-wave-dots span:nth-child(6),
.voice-wave-dots span:nth-child(7),
.voice-wave-dots span:nth-child(8) {
    width: 7px;
    height: 7px;
    background: rgba(255, 255, 255, 0.8);
}
@keyframes voiceWave {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.4); opacity: 1; }
}

/* ===== Dock 输入区 ===== */
.input-dock {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(245, 246, 248, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 12px;
}

.voice-status {
    position: absolute;
    top: -34px;
    left: 16px;
    right: 16px;
    text-align: center;
    background: rgba(0, 0, 0, 0.72);
    color: var(--paper);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
    z-index: 50;
}

.dock-plus-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #e8eaed;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    cursor: pointer;
}
.dock-plus-btn:active { background: #d5d8dc; }

.dock-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}
.dock-input {
    width: 100%;
    height: 40px;
    border-radius: 20px;
    border: 1px solid #e0e3e8;
    background: #f0f1f3;
    padding: 0 60px 0 16px;
    font-size: 14px;
    color: #3d4650;
    box-sizing: border-box;
    outline: none;
}
.dock-input::placeholder { color: #a0a5ab; }
.dock-input:focus { border-color: #c0c5cc; background: var(--paper); }
.dock-count {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: #a0a5ab;
    pointer-events: none;
}

.dock-voice-bar {
    flex: 1;
    height: 40px;
    border-radius: 20px;
    border: 1px solid #e0e3e8;
    background: #f0f1f3;
    font-size: 16px;
    font-weight: 500;
    color: #3d4650;
    letter-spacing: 2px;
    user-select: none;
    cursor: pointer;
    display: none;
}
.dock-voice-bar:active,
.dock-voice-bar.active {
    background: #e3e5e8;
    border-color: #c0c5cc;
}

.dock-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #e8eaed;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    cursor: pointer;
}
.dock-icon-btn:active { background: #d5d8dc; }

.dock-voice-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #4a3dba;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    user-select: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(74, 61, 186, 0.3);
}
.dock-voice-btn:active,
.dock-voice-btn.listening {
    background: #3a2d9a;
    box-shadow: 0 2px 12px rgba(74, 61, 186, 0.5);
}

.dock-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary, var(--navy));
    color: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    cursor: pointer;
}
.dock-send-btn:active { opacity: 0.9; }

/* ===== 聊天附件 chips ===== */
.chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
    min-height: 0;
}
.chat-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: var(--navy-soft, #eef4fb);
    border: 1px solid var(--line-soft, #eef2f6);
    border-radius: 6px;
    font-size: 12px;
    color: var(--navy, #173d6d);
    max-width: 100%;
}
.chat-attachment-chip .chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}
.chat-attachment-chip .chip-remove {
    background: none;
    border: none;
    color: var(--muted, #7c8999);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}
.chat-attachment-chip .chip-remove:hover { color: var(--ink, #27384c); }

/* ===== 中央工作台 Stage ===== */
#workspace-stage {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
#workspace-stage.active {
    display: flex;
}

.workspace-stage-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    background: var(--paper);
}
.workspace-stage-back-btn,
.workspace-stage-collapse-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    border-radius: 6px;
}
.workspace-stage-back-btn:hover,
.workspace-stage-collapse-btn:hover {
    background: var(--line-soft);
    color: var(--ink);
}
.workspace-stage-tabs {
    flex: 1;
    display: flex;
    border-bottom: none;
}
.workspace-stage-tabs .stage-tab {
    flex: 1;
    padding: 12px 6px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.workspace-stage-tabs .stage-tab:hover { color: var(--ink); }
.workspace-stage-tabs .stage-tab.active {
    color: var(--navy);
    border-bottom-color: var(--navy);
}
.workspace-stage-tabs .stage-tab.locked {
    color: var(--muted-2);
    cursor: not-allowed;
}
.workspace-stage-tabs .stage-tab.locked:hover {
    color: var(--muted-2);
    border-bottom-color: transparent;
}
.workspace-stage-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

/* 聊天模式与投资分析模式互斥 */
#chat-main.investment-mode > header,
#chat-main.investment-mode > .flex-1,
#chat-main.investment-mode > footer {
    display: none !important;
}
#chat-main.investment-mode > #workspace-stage {
    display: flex;
}

/* ===== 底部工作台 Sheet ===== */
#investment-workspace {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(70vh + env(safe-area-inset-bottom));
    max-height: 720px;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--paper);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: 0 -8px 32px rgba(18,31,47,.18);
    z-index: 1002;
    transform: translateY(102%);
    transition: transform 0.28s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#investment-workspace.open {
    transform: translateY(0);
}
#investment-workspace .workspace-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}
#investment-workspace .workspace-project-name {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    color: var(--navy);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#investment-workspace .workspace-back-btn,
#investment-workspace .workspace-collapse-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--muted);
    border-radius: 8px;
    cursor: pointer;
}
#investment-workspace .workspace-back-btn:hover,
#investment-workspace .workspace-collapse-btn:hover {
    background: var(--line-soft);
    color: var(--ink);
}
#investment-workspace .workspace-stage-tabs {
    flex-shrink: 0;
}
#investment-workspace .workspace-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
.workspace-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18,31,47,.32);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.workspace-sheet-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
body.workspace-open .mobile-bottom-tabs {
    transform: translateY(100%);
}

/* 工作台占位 */
.workspace-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted);
    gap: 12px;
}
.workspace-placeholder .ph-icon {
    font-size: 48px;
    opacity: 0.3;
}
.workspace-placeholder .ph-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
}
.workspace-placeholder .ph-desc {
    font-size: 13px;
    color: var(--muted-2);
}