@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Merriweather:wght@400;700&display=swap');

:root {
  --bg: #09090b; --bg-2: #18181b; --bg-3: #27272a;
  --border: #3f3f46; --text: #f4f4f5; --text-muted: #a1a1aa;
  --accent: #7c3aed; --accent-hover: #6d28d9;
  --radius: 12px; --font: 'Inter', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

/* SCREEN */
.screen { position: fixed; inset: 0; display: none; opacity: 0; transition: opacity 0.5s; z-index: 10; }
.screen.active { display: flex; opacity: 1; z-index: 20; }

/* LOGIN (ISEKAI GATE) */
#gateScreen { align-items: center; justify-content: center; overflow: hidden; }
.gate-bg { position: absolute; inset: 0; background: url('/static/assets/gerbang.png') center/cover; z-index: -1; transition: transform 3s cubic-bezier(0.25, 1, 0.5, 1), filter 3s; filter: brightness(0.5) blur(2px); animation: slowPan 20s infinite alternate; }
@keyframes slowPan { from{transform:scale(1)} to{transform:scale(1.1)} }
#gateScreen.opening .gate-bg { transform: scale(4); filter: brightness(3) blur(10px); }
#gateScreen.opening .dialog-box { transform: translateY(-100px) scale(0.8); opacity: 0; }

.dialog-box { position: relative; z-index: 3; background: rgba(24, 24, 27, 0.65); backdrop-filter: blur(24px); border: 1px solid rgba(255,255,255,0.1); border-left: 4px solid var(--accent); padding: 40px; border-radius: 16px; width: 90%; max-width: 420px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8); transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1); animation: floatBox 6s ease-in-out infinite; }
@keyframes floatBox { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.dialog-title { color: #fff; font-size: 24px; letter-spacing: 4px; margin-bottom: 10px; font-weight: 800; text-shadow: 0 0 20px var(--accent); }
.dialog-text { font-size: 14px; line-height: 1.6; color: #aaa; margin-bottom: 30px; }
.input-row { position: relative; margin-bottom: 16px; }
.input-row input { width: 100%; padding: 16px; background: rgba(0,0,0,0.4); border: 1px solid var(--border); border-radius: var(--radius); color: #fff; font-size: 15px; outline: none; transition: 0.3s; }
.input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,0.2); background: rgba(0,0,0,0.6); }
.toggle-pass { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); cursor: pointer; opacity: 0.6; }
.btn-group { display: flex; gap: 12px; margin-top: 24px; }
.btn-action, .btn-magic { flex: 1; padding: 14px; border-radius: var(--radius); border: none; font-weight: 600; font-size: 15px; cursor: pointer; transition: 0.3s; }
.btn-action { background: var(--accent); color: #fff; box-shadow: 0 4px 15px rgba(124,58,237,0.4); }
.btn-action:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn-magic { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
.btn-magic:hover { background: rgba(124,58,237,0.1); }
.btn-text { background: none; border: none; color: var(--text-muted); cursor: pointer; margin-top: 20px; width: 100%; font-size: 14px; transition: 0.2s; }
.btn-text:hover { color: #fff; }
.otp-input { width: 100%; padding: 16px; font-size: 28px; text-align: center; letter-spacing: 10px; background: rgba(0,0,0,0.4); border: 2px solid var(--accent); border-radius: var(--radius); color: #fff; font-weight: bold; }

/* PORTAL TRANSISI */
#portalScreen { align-items: center; justify-content: center; background: #000; }
.portal-bg { position: absolute; inset: 0; background: url('/static/assets/gerbang_kebuka.png') center/cover; filter: brightness(0.2); animation: zoomPortal 5s infinite alternate; }
@keyframes zoomPortal { from{transform:scale(1)} to{transform:scale(1.1)} }
.portal-flash { position: absolute; inset: 0; background: #fff; opacity: 0; animation: flash 3s ease-out forwards; z-index: 5; }
@keyframes flash { 0%{opacity:0} 10%{opacity:1} 100%{opacity:0} }
.portal-text { color: #fff; font-size: 22px; letter-spacing: 6px; z-index: 10; animation: pulse 1.5s infinite; }

/* WORKSPACE UI */
#app { display: none; width: 100%; height: 100%; background: var(--bg); }
#app.active { display: flex; }
.workspace-layout { display: flex; width: 100%; height: 100%; }
.sidebar { width: 260px; background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: transform 0.3s; flex-shrink: 0; }
.sidebar-header { padding: 20px 16px; }
.logo { font-weight: 800; font-size: 20px; letter-spacing: 2px; margin-bottom: 20px; color: var(--accent); }
.new-chat-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius); color: #fff; font-weight: 600; cursor: pointer; transition: 0.2s; }
.new-chat-btn:hover { background: var(--accent); border-color: var(--accent); }
.sidebar-nav { padding: 0 8px; display: flex; flex-direction: column; gap: 4px; margin-bottom: 20px; }
.nav-item { padding: 12px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text-muted); display: flex; justify-content: space-between; transition: 0.2s; }
.nav-item:hover, .nav-item.active { background: var(--bg-3); color: #fff; }
.badge { font-size: 10px; background: var(--border); padding: 2px 6px; border-radius: 4px; }
.sidebar-history { flex: 1; overflow-y: auto; padding: 0 8px; }
.history-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; padding-left: 16px; font-weight: 600; }
.conv-item { padding: 12px 16px; border-radius: 8px; cursor: pointer; color: var(--text-muted); font-size: 14px; display: flex; justify-content: space-between; margin-bottom: 2px; transition: 0.2s; }
.conv-item:hover, .conv-item.active { background: var(--bg-3); color: #fff; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.provider-wrap { margin-bottom: 16px; }
.provider-select { width: 100%; padding: 10px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; color: #fff; outline: none; font-size: 13px; }
.user-profile { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: bold; }
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-status { font-size: 12px; color: var(--text-muted); }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 18px; opacity: 0.6; transition: 0.2s; }
.icon-btn:hover { opacity: 1; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-header { height: 64px; display: flex; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--border); justify-content: space-between; background: var(--bg); }
.model-selector { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; background: var(--bg-2); padding: 8px 16px; border-radius: 24px; border: 1px solid var(--border); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; box-shadow: 0 0 10px #22c55e; }

.chat-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.welcome-view { max-width: 800px; margin: auto; text-align: center; padding: 60px 20px; display: flex; flex-direction: column; align-items: center; }
.welcome-icon { font-size: 48px; color: var(--accent); margin-bottom: 20px; text-shadow: 0 0 30px var(--accent); }
.welcome-view h1 { font-size: 36px; font-weight: 800; margin-bottom: 12px; }
.welcome-view p { color: var(--text-muted); margin-bottom: 48px; font-size: 18px; }
.shortcut-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; width: 100%; }
.shortcut-card { display: flex; flex-direction: column; align-items: flex-start; padding: 24px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; transition: 0.3s; text-align: left; }
.shortcut-card:hover { background: var(--bg-3); border-color: var(--accent); transform: translateY(-4px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); }
.sc-icon { font-size: 28px; margin-bottom: 16px; }
.sc-title { font-weight: 700; color: #fff; margin-bottom: 6px; font-size: 16px; }
.sc-desc { font-size: 14px; color: var(--text-muted); }

.messages-container { max-width: 800px; margin: 0 auto; width: 100%; padding: 24px; display: flex; flex-direction: column; gap: 32px; }
.msg { display: flex; gap: 20px; }
.msg .avatar { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; }
.msg.user .avatar { background: var(--bg-3); color: #fff; }
.msg.bot .avatar { background: linear-gradient(135deg, var(--accent), #4c1d95); color: #fff; }
.msg .content { flex: 1; line-height: 1.7; font-size: 16px; min-width: 0; word-wrap: break-word; }
.msg .content pre { background: #000; padding: 20px; border-radius: 12px; overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); }

.composer-area { padding: 24px; background: var(--bg); }
.composer-box { max-width: 800px; margin: 0 auto; display: flex; align-items: flex-end; background: var(--bg-2); border: 1px solid var(--border); border-radius: 24px; padding: 8px 8px 8px 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); transition: 0.3s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,0.2); }
#input { flex: 1; background: transparent; border: none; color: #fff; font-size: 16px; resize: none; max-height: 200px; padding: 12px 0; outline: none; font-family: inherit; }
.send-btn { background: var(--accent); border: none; border-radius: 16px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; color: #fff; cursor: pointer; flex-shrink: 0; transition: 0.2s; }
.send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
.send-btn svg { width: 20px; height: 20px; }
.disclaimer { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 16px; }

@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
.mobile-only { display: none; }
@media (max-width: 768px) {
  .sidebar { position: fixed; height: 100%; z-index: 100; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: block; }
  .shortcut-grid { grid-template-columns: 1fr; }
}
