/* ========================================================== */
/* ==    GPTba v3.5 Style - Project Terminus (Final)       == */
/* ========================================================== */

:root {
    --brand-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --brand-gradient-secondary: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%);
    --bg-main: #121212;
    --bg-surface: #1E1E1E;
    --bg-glass: rgba(20, 20, 20, 0.6);
    --bg-surface-high: #2C2C2C;
    --primary-color: #A37BFF;
    --on-primary-color: #FFFFFF;
    --primary-container-color: #4A3F9A;
    --on-primary-container-color: #E6DEFF;
    --secondary-container-color: #3E4856;
    --on-secondary-container-color: #DDE3F7;
    --text-color: #EAEAEA;
    --text-variant-color: #A0A0A0;
    --outline-color: #333333;
    --shadow-color: rgba(120, 80, 255, 0.2);
    --safe-area-inset-top: env(safe-area-inset-top, 0);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0);
    --safe-area-inset-left: env(safe-area-inset-left, 0);
    --safe-area-inset-right: env(safe-area-inset-right, 0);
}

body.light-mode {
    --brand-gradient: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%);
    --brand-gradient-secondary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-main: #F4F7FC;
    --bg-surface: #FFFFFF;
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-surface-high: #F0F4F9;
    --primary-color: #6A5AE0;
    --on-primary-color: #FFFFFF;
    --primary-container-color: #E2DFFF;
    --on-primary-container-color: #21125A;
    --secondary-container-color: #E0E0FF;
    --on-secondary-container-color: #1A1A5A;
    --text-color: #1A1C1E;
    --text-variant-color: #5A5A5A;
    --outline-color: #DDE1E6;
    --shadow-color: rgba(100, 100, 200, 0.15);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }

* { box-sizing: border-box; }
html { height: 100%; }
body { font-family: 'Noto Sans SC', 'Roboto', sans-serif; margin: 0; background: var(--bg-main); color: var(--text-color); transition: background 0.5s ease, color 0.5s ease; line-height: 1.6; -webkit-font-smoothing: antialiased; overflow: hidden; height: 100%; }
#root { height: 100dvh; display: flex; flex-direction: column; }
.app-layout { display: flex; flex-grow: 1; width: 100%; height: 100%; overflow: hidden; }
.chat-view { flex-grow: 1; display: flex; flex-direction: column; height: 100%; overflow: hidden; background-color: var(--bg-surface); border-radius: 24px 0 0 24px; box-shadow: -10px 0px 30px rgba(0,0,0,0.1); animation: fadeInUp 0.5s ease-out; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--outline-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-variant-color); }
.nav-rail { display: flex; flex-direction: column; align-items: center; width: 96px; padding: 16px 0; gap: 12px; transition: background-color 0.3s; background: transparent; animation: fadeInUp 0.3s ease-out; }
.nav-header { margin-bottom: 24px; color: var(--primary-color); cursor: pointer; transition: transform 0.3s ease; }
.nav-header:hover { transform: rotate(15deg); }
.nav-header svg { width: 36px; height: 36px; }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 80px; height: 72px; padding: 8px 4px; border-radius: 24px; text-decoration: none; color: var(--text-variant-color); transition: all 0.2s ease-in-out; cursor: pointer; }
.nav-item .icon-container { width: 56px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 16px; margin-bottom: 4px; transition: all 0.2s ease-in-out; }
.nav-item svg { width: 24px; height: 24px; transition: all 0.2s ease; }
.nav-item .label { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; text-align: center; }
.nav-item:hover svg { color: var(--primary-color); }
.nav-item.active { color: var(--on-primary-color); background: var(--brand-gradient-secondary); box-shadow: 0 4px 15px var(--shadow-color); }
.nav-item.active .label { font-weight: 700; }
.nav-item.active svg { color: var(--on-primary-color); }
.nav-spacer { flex-grow: 1; }
#theme-toggle { color: var(--text-variant-color); }
.header { flex-shrink: 0; padding: 16px 24px; padding-top: calc(16px + var(--safe-area-inset-top)); display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 10; background-color: var(--bg-glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--outline-color); border-radius: 24px 0 0 0; }
.title-area h1 { margin: 0; font-size: 22px; color: var(--text-color); font-weight: 700; }
.title-area .subtitle { margin: 2px 0 0 0; font-size: 14px; color: var(--text-variant-color); }
.controls { display: flex; align-items: center; gap: 12px; }
.controls select, .controls button { background-color: var(--bg-surface-high); border: 1px solid var(--outline-color); color: var(--text-variant-color); padding: 8px 16px; border-radius: 12px; cursor: pointer; font-size: 14px; transition: all 0.2s; -webkit-appearance: none; appearance: none; }
.controls select:hover, .controls button:hover { border-color: var(--primary-color); color: var(--primary-color); }
.controls button { padding: 8px; border-radius: 50%; }
.controls button svg { width: 20px; height: 20px; }
.chat-window { flex-grow: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; position: relative; -webkit-overflow-scrolling: touch; }
.message { display: flex; max-width: 80%; margin-bottom: 12px; align-items: flex-end; animation: scaleIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both; }
.message-content { padding: 12px 20px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; border-radius: 24px; box-shadow: 0 4px 10px var(--shadow-color); }
.user-message { margin-left: auto; flex-direction: row-reverse; }
.user-message .message-content { background: var(--primary-container-color); color: var(--on-primary-container-color); border-bottom-right-radius: 6px; }
.ai-message { margin-right: auto; }
.ai-message .message-content { background: var(--bg-surface-high); color: var(--text-color); border-bottom-left-radius: 6px; }
.empty-chat-placeholder { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; margin: auto; color: var(--text-variant-color); animation: fadeInUp 0.5s 0.2s ease-out both; transition: opacity 0.3s ease; }
.empty-chat-placeholder .logo { width: 80px; height: 80px; margin-bottom: 24px; background: var(--brand-gradient); border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: 0 0 30px var(--shadow-color); }
.empty-chat-placeholder .logo svg { width: 48px; height: 48px; color: white; }
.empty-chat-placeholder h2 { margin: 0; font-size: 24px; color: var(--text-color); }
.empty-chat-placeholder p { margin-top: 8px; }
.input-area { flex-shrink: 0; padding: 16px 24px; padding-bottom: calc(16px + var(--safe-area-inset-bottom)); border-top: 1px solid var(--outline-color); display: flex; align-items: flex-end; gap: 16px; background: transparent; }
#message-input { flex-grow: 1; background-color: var(--bg-surface-high); border: 1px solid var(--outline-color); border-radius: 24px; padding: 14px 24px; color: var(--text-color); outline: none; font-size: 16px; resize: none; transition: all 0.3s ease; max-height: 150px; }
#message-input:focus { border-color: var(--primary-color); box-shadow: 0 0 10px var(--shadow-color); }
#send-button { flex-shrink: 0; width: 52px; height: 52px; background: var(--brand-gradient); color: var(--on-primary-color); border: none; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; box-shadow: 0 4px 15px var(--shadow-color); }
#send-button:hover { transform: scale(1.1); filter: brightness(1.1); }
#send-button:disabled { background: var(--secondary-container-color); cursor: not-allowed; transform: scale(1); filter: none; box-shadow: none; }
#send-button svg { width: 24px; height: 24px; }
#typing-indicator .message-content { background: var(--bg-surface-high) !important; box-shadow: 0 4px 10px var(--shadow-color) !important; }
.typing-indicator span { height: 8px; width: 8px; margin: 0 3px; background-color: var(--text-variant-color); border-radius: 50%; display: inline-block; animation: bounce 1.4s infinite ease-in-out both; }
.typing-indicator span:nth-of-type(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-of-type(2) { animation-delay: -0.16s; }
#update-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn 0.3s ease; }
.update-modal-content { background: var(--bg-surface); padding: 24px 32px; border-radius: 16px; border: 1px solid var(--outline-color); box-shadow: 0 10px 30px rgba(0,0,0,0.2); max-width: 90%; width: 500px; position: relative; animation: scaleIn 0.3s ease; }
#close-update-modal { position: absolute; top: 12px; right: 12px; background: transparent; border: none; color: var(--text-variant-color); font-size: 24px; line-height: 1; cursor: pointer; padding: 8px; transition: transform 0.2s, color 0.2s; }
#close-update-modal:hover { transform: rotate(90deg); color: var(--primary-color); }
.update-modal-content h2 { margin-top: 0; margin-bottom: 16px; color: var(--text-color); font-size: 22px; }
.update-modal-content #update-modal-body ul { list-style-type: '✨'; padding-left: 20px; margin: 0; color: var(--text-variant-color); }
.update-modal-content #update-modal-body li { padding-left: 10px; margin-bottom: 10px; }
.bottom-nav { display: none; }
@media (max-width: 768px) {
    #root { height: 100%; }
    .app-layout { flex-direction: column; height: 100%; }
    .nav-rail { display: none; }
    .chat-view { height: 100%; border-radius: 0; box-shadow: none; }
    .header, .input-area { padding-left: calc(16px + var(--safe-area-inset-left)); padding-right: calc(16px + var(--safe-area-inset-right)); }
    .header { border-radius: 0; }
    .bottom-nav { display: flex; flex-shrink: 0; order: 2; justify-content: space-around; align-items: flex-start; background-color: var(--bg-glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); height: calc(80px + var(--safe-area-inset-bottom)); padding-top: 8px; padding-bottom: var(--safe-area-inset-bottom); padding-left: var(--safe-area-inset-left); padding-right: var(--safe-area-inset-right); border-top: 1px solid var(--outline-color); }
    .bottom-nav .nav-item { width: auto; flex: 1; height: 100%; padding: 4px 0; border-radius: 16px; }
    .bottom-nav .nav-header, .bottom-nav .nav-spacer { display: none; }
    .title-area h1 { font-size: 18px; }
}