:root {
    --bb-red: #FF2442;
    --bb-red-light: rgba(255, 36, 66, 0.15);
    --bg-white: #FFFFFF;
    --bg-gray: #F9FAFB;
    --border-color: rgba(0, 0, 0, 0.15);
    --text-main: #1D1D1F;
    --text-muted: #86868B;
    --panel-width: 320px;
    --glass-shadow: 0 4px 24px 0 rgba(0, 0, 0, 0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { position: fixed; top: 0; left: 0; right: 0; bottom: 0; height: 100%; width: 100%; overflow: hidden; }
body { font-family: 'Outfit', 'Noto Sans TC', sans-serif; background-color: #FFFFFF;  color: var(--text-main); }
button, input, select { font-family: inherit; outline: none; }

.app-container { display: flex; height: 100%; }

.sidebar { width: 68px; background-color: #FFFFFF; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; align-items: center; padding: 15px 0; z-index: 10; overflow-y: auto; box-shadow: 1px 0 15px rgba(0,0,0,0.03); }
.sidebar::-webkit-scrollbar { display: none; }
.sidebar { width: 68px; background-color: #FFFFFF; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; align-items: center; padding: 15px 0; z-index: 10; overflow-y: auto; box-shadow: 1px 0 15px rgba(0,0,0,0.03); }

.logo { width: 40px; min-height: 40px; background: linear-gradient(135deg, #FF2442, #E3001B); color: white; border-radius: 12px; display: flex; justify-content: center; align-items: center; font-size: 20px; font-weight: 700; margin-bottom: 20px; box-shadow: 0 4px 0 #D0001D, 0 4px 8px rgba(255, 36, 66, 0.25); border: 2px solid #FF2442; transform: translateY(-2px); }
.nav-group { display: flex; flex-direction: column; gap: 10px; flex: 1; align-items: center; width: 100%;}
.nav-btn { width: 42px; height: 42px; border: none; background: none; color: var(--text-muted); font-size: 18px; border-radius: 10px; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }
.nav-btn:hover { color: var(--bb-red); background-color: var(--bb-red-light); }
.nav-btn.active { color: white; background-color: var(--bb-red); }
.nav-btn.active i { color: white !important; }
.nav-divider { height: 1px; background-color: var(--border-color); width: 30px; margin: 5px auto; flex-shrink: 0; }
.nav-bottom { margin-top: auto; padding-top: 15px; }
.avatar-small { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border-color); }

.assignee-option {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}
.assignee-option:hover {
    background-color: var(--bg-gray);
}

.text-admin { color: #8E24AA; }
.text-admin:hover { background-color: #FFFFFF; color: #6A1B9A; }
.border-admin { border-color: #8E24AA; border-width: 3px; }

.chat-panel { width: var(--panel-width); background-color: #FFFFFF; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; position: relative; overflow: hidden; transition: 0.3s; box-shadow: var(--glass-shadow); }
.chat-panel.collapsed { margin-left: calc(var(--panel-width) * -1); }
.view-layer { position: absolute; top:0; left:0; width:100%; height:100%; display: flex; flex-direction: column; background: transparent; transition: 0.3s; }
.view-layer.hidden { opacity: 0; pointer-events: none; transform: translateX(-30px); }

.panel-header { height: 60px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; padding: 0 15px; flex-shrink:0; background-color: #FFFFFF; }
.panel-header h2 { font-size: 16px; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 16px; width: 30px; height: 30px; color: var(--text-muted); }

.chat-list { flex: 1; overflow-y: auto; }
.list-item { display: flex; padding: 12px 15px; gap: 10px; cursor: pointer; border-bottom: 1px solid rgba(0,0,0,0.03); transition: 0.2s; }
.list-item:hover { background-color: #FFFFFF; }
.item-avatar { width: 36px; height: 36px; background-color: var(--text-main); color: white; border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 14px; font-weight: bold; }
.item-avatar.bg-red { background-color: var(--bb-red); }
.item-content { flex: 1; min-width: 0; }
.item-top { display: flex; justify-content: space-between; margin-bottom: 4px;}
.item-top .name { font-size: 14px; font-weight: 500; }
.chat-input { height: 60px; display: flex; align-items: center; padding: 0 10px; background-color: transparent; border-top: 1px solid var(--border-color); }
.chat-input input { flex: 1; border: 1px solid rgba(0,0,0,0.05); background-color: #FFFFFF; padding: 10px 15px; border-radius: 20px; font-size: 14px; margin-right: 10px;  box-shadow: inset 0 1px 3px rgba(0,0,0,0.02); transition: 0.2s; }
.chat-input input:focus { background-color: #FFFFFF; outline: none; border-color: rgba(255, 45, 85, 0.3); }
.send-btn { background: none; border: none; color: var(--bb-red); font-size: 18px; cursor: pointer; }

.workspace { flex: 1; display: flex; flex-direction: column; background-color: var(--bg-gray); }
.workspace-header { height: 60px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 20px; background-color: #FFFFFF; box-shadow: 0 1px 10px rgba(0,0,0,0.02); z-index: 5; }
.expand-chat-btn { background: none; border: 1px solid var(--border-color); padding: 6px 12px; border-radius: 6px; margin-right: 15px; cursor: pointer; color: var(--text-muted); font-size: 13px; }
.iframe-container { flex: 1; position: relative; }
.iframe-container iframe { width: 100%; height: 100%; border: none; }
.welcome-screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; background-color: transparent; }
.welcome-logo { font-size: 48px; font-weight: 800; color: var(--bb-red-light); margin-bottom: 15px; }

/* 後台管理介面 */
.admin-panel { position: absolute; top:0; left:0; width:100%; height:100%; background-color: transparent; padding: 30px; overflow-y: auto; }
.admin-grid { display: grid; grid-template-columns: 450px 1fr; gap: 30px; max-width: 1400px; margin: 0 auto; }
.admin-card { background: var(--bg-white); padding: 25px; border-radius: 20px; box-shadow: var(--glass-shadow);  -webkit- border: 1px solid var(--border-color); }
.admin-card h3 { font-size: 18px; margin-bottom: 20px; color: #8E24AA; display: flex; align-items: center; gap: 10px; }

.form-row { display: flex; gap: 15px; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.form-group input, .form-group select { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 14px; }
.btn-admin-submit { width: 100%; padding: 12px; background-color: var(--bb-red); color: white; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; transition: 0.2s; margin-top: 10px;}
.btn-admin-submit:hover { background-color: #c90010; }

/* 複選框 Grid 排版 */
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: var(--bg-gray); padding: 15px; border-radius: 8px; border: 1px solid var(--border-color); }
.checkbox-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-main); cursor: pointer; }
.checkbox-item input { width: 16px; height: 16px; margin: 0; cursor: pointer; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.tag-role { padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: bold; }
.tag-admin { background: #F3E5F5; color: #8E24AA; }
.tag-manager { background: #E3F2FD; color: #1976D2; }
.tag-staff { background: #F5F5F5; color: #616161; }
.hidden { display: none !important; }

/* 登入視窗 */
.login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 9999; display: flex; justify-content: center; align-items: center; }
.login-card { background: #FFFFFF;  -webkit- padding: 40px; border-radius: 24px; width: 100%; max-width: 400px; box-shadow: var(--glass-shadow); border: 1px solid rgba(255,255,255,0.5); }
.login-logo { font-size: 28px; font-weight: 800; color: var(--bb-red); text-align: center; margin-bottom: 5px; letter-spacing: 2px; }

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .app-container { flex-direction: column-reverse; }
    
    /* Bottom Navigation Bar for Mobile - 覆寫桌面版 sidebar 成底部橫向列 */
    .sidebar {
        width: 100% !important;
        height: 56px !important;
        min-height: 56px !important;
        flex-direction: row !important;
        padding: 0 8px !important;
        border-right: none !important;
        border-top: 1px solid var(--border-color) !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05) !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        flex-shrink: 0 !important;
        align-items: center !important;
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    }
    .nav-group { flex-direction: row; justify-content: flex-start; align-items: center; width: 100%; height: 100%; overflow-x: auto; gap: 4px; scrollbar-width: none; flex: 1; }
    .nav-group::-webkit-scrollbar { display: none; }
    .nav-divider { width: 1px; height: 24px; margin: 0 4px; }
    .logo { display: none; }
    .nav-btn { width: 44px; height: 44px; flex-shrink: 0; }
    
    /* Move User Avatar to the end of scrollable nav */
    .nav-bottom { padding: 0; display: flex; align-items: center; margin-left: auto; flex-shrink: 0; }
    .avatar-small { width: 32px; height: 32px; }
    
    /* Panels */
    .chat-panel { width: 100%; background-color: #FFFFFF; border-right: none; display: flex; flex-direction: column; position: absolute; top: 0; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom, 0px)); overflow: hidden; transition: 0.3s; box-shadow: var(--glass-shadow); z-index: 5; }
    .chat-panel.collapsed { transform: translateX(-100%); }
    
    .workspace { height: calc(100% - 56px - env(safe-area-inset-bottom, 0px)); width: 100%; }
    .workspace-header { height: 56px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 15px; background-color: #FFFFFF; box-shadow: 0 1px 10px rgba(0,0,0,0.02); z-index: 5; }
    .workspace-header h2 { font-size: 15px; }
    .expand-chat-btn { padding: 5px 10px; font-size: 12px; margin-right: 10px; }
    
    /* Admin Panel */
    .admin-panel { padding: 15px; }
    .admin-grid { grid-template-columns: 1fr; gap: 15px; }
    .admin-card { padding: 15px; }
    .form-row { flex-direction: column; gap: 0; }
    .checkbox-grid { grid-template-columns: 1fr; }
    
    /* Modern Task Modal */
    .modal-content { width: 95% !important; margin: auto; }
}

/* Markdown Styles in Chat */
.markdown-body { font-family: inherit; font-size: inherit; }
.markdown-body p { margin-bottom: 8px; white-space: pre-wrap; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin-bottom: 8px; }
.markdown-body ul:last-child, .markdown-body ol:last-child { margin-bottom: 0; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body strong { font-weight: 700; color: #b71c1c; } /* Reddish bold for emphasis */
.markdown-body a { color: #1976d2; text-decoration: underline; }
.markdown-body blockquote { border-left: 3px solid #ccc; padding-left: 10px; color: #555; margin-bottom: 8px; }

.reaction-trigger:hover .reaction-menu { display: flex !important; animation: popIn 0.2s ease-out; }
@keyframes popIn { 0% { transform: translate(-50%, 10px) scale(0.8); opacity: 0; } 100% { transform: translate(-50%, 0) scale(1); opacity: 1; } }


/* Gaming Button Styles */
.btn-game-primary {
    background: #FF2442 !important;
    color: #FFFFFF !important;
    border-radius: 12px !important;
    border: 2px solid #FF2442 !important;
    box-shadow: 0 4px 0 #CC102A, 0 5px 15px rgba(255,36,66,0.3) !important;
    font-weight: 800 !important;
    transition: all 0.1s !important;
}
.btn-game-primary:active {
    box-shadow: 0 0 0 #CC102A !important;
    transform: translateY(4px) !important;
}
.btn-game-secondary {
    background: #FFFFFF !important;
    color: #FF2442 !important;
    border-radius: 12px !important;
    border: 2px solid #FF2442 !important;
    box-shadow: 0 4px 0 #FF2442 !important;
    font-weight: 800 !important;
    transition: all 0.1s !important;
}
.btn-game-secondary:active {
    box-shadow: 0 0 0 #FF2442 !important;
    transform: translateY(4px) !important;
}

.workspace-header h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
