:root {
    --bg-color: #121212;
    --header-bg: #181818;
    --chat-bg: #0d0d0d;
    --input-bg: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #888888;
    --user-bubble: #2b2b2b;
    --bot-bubble: #181818;
    --border-color: #333;
    --badge-bg: rgba(255, 255, 255, 0.08);
}

/* RESET & LAYOUT */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; width: 100%; background: var(--bg-color); color: var(--text-primary); overflow: hidden; position: fixed; }

.main-container { display: flex; flex-direction: column; height: 100%; width: 100%; max-width: 600px; margin: 0 auto; background: var(--chat-bg); position: relative; }

/* HEADER */
.header { 
    flex-shrink: 0; background: var(--header-bg); padding: 15px 20px; 
    display: flex; justify-content: space-between; align-items: center; 
    border-bottom: 1px solid var(--border-color); z-index: 10; 
}
.header-left { display: flex; align-items: center; gap: 15px; height: 100%; }
.bot-info { display: flex; flex-direction: column; justify-content: center; }
.header h2 { font-size: 1.1rem; font-weight: 700; margin: 0; line-height: 1.2; }
.status-indicator { width: 8px; height: 8px; background: #10b981; border-radius: 50%; display: inline-block; margin-top: 2px;}
.btn-icon { background: none; border: none; color: var(--text-primary); font-size: 1.2rem; cursor: pointer; padding: 5px; display: flex; align-items: center;}

/* CHAT BOX */
.chat-box { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; scroll-behavior: smooth; position: relative; }

/* BUBBLES */
.message { display: flex; flex-direction: column; max-width: 90%; }
.user-message { align-self: flex-end; align-items: flex-end; }
.bot-message { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 10px 14px; border-radius: 16px; position: relative; line-height: 1.4; font-size: 0.95rem; word-wrap: break-word; }
.user-message .bubble { background: var(--user-bubble); color: white; border-bottom-right-radius: 4px; }
.bot-message .bubble { background: var(--bot-bubble); color: var(--text-primary); border-bottom-left-radius: 4px; border: 1px solid #222; }
.img-attachment { width: 100%; max-width: 250px; border-radius: 12px; margin-bottom: 8px; border: 1px solid #333; }

/* ACTIONS BUTTONS */
.msg-actions { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin-top: 8px; 
    flex-wrap: wrap; 
    padding-top: 5px; 
    border-top: 1px solid rgba(255,255,255,0.05); 
}

.action-btn { 
    background: rgba(255,255,255,0.05); 
    border: 1px solid transparent; 
    color: #e0e0e0; 
    font-size: 0.75rem; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    padding: 4px 10px; 
    border-radius: 6px; 
    transition: all 0.2s; 
}

.action-btn:hover { 
    background: rgba(255,255,255,0.15); 
    color: white; 
    transform: translateY(-1px); 
}

/* WARNA KHUSUS TOMBOL EXPORT */
.btn-export-word { color: #3b82f6; border-color: rgba(59, 130, 246, 0.3); } 
.btn-export-word:hover { background: rgba(59, 130, 246, 0.1); }

.btn-export-pdf { color: #ef4444; border-color: rgba(239, 68, 68, 0.3); } 
.btn-export-pdf:hover { background: rgba(239, 68, 68, 0.1); }

.btn-export-excel { color: #10b981; border-color: rgba(16, 185, 129, 0.3); } 
.btn-export-excel:hover { background: rgba(16, 185, 129, 0.1); }

/* MARKDOWN STYLES */
.bubble h1, .bubble h2, .bubble h3 { margin: 12px 0 6px 0; font-weight: 700; color: #fff; }
.bubble h1 { font-size: 1.3rem; border-bottom: 1px solid #444; padding-bottom: 5px; } 
.bubble h2 { font-size: 1.1rem; }
.bubble p { margin-bottom: 8px; }
.bubble ul, .bubble ol { margin-left: 20px; margin-bottom: 10px; }
.bubble li { margin-bottom: 4px; }
.bubble strong { color: #e2e8f0; font-weight: 700; }
.bubble code { background: rgba(255,255,255,0.15); padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 0.9em; color: #ff79c6; }
.bubble pre { background: #1e1e1e !important; padding: 12px; border-radius: 8px; overflow-x: auto; margin: 10px 0; border: 1px solid #333; }
.bubble pre code { background: transparent; padding: 0; color: #abb2bf; font-size: 0.85rem;}
.bubble table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.85rem; }
.bubble th, .bubble td { border: 1px solid #444; padding: 8px; text-align: left; }
.bubble th { background: #2d2d2d; color: #fff; }

/* MODE INDICATOR */
.mode-indicator { 
    background: #2d1b4e; color: #d8b4fe; 
    padding: 8px 15px; font-size: 0.85rem; font-weight: 500;
    display: flex; justify-content: space-between; align-items: center; 
    border-top: 1px solid #4c1d95; 
}
#btnCancelMode { 
    background: rgba(0, 0, 0, 0.2); 
    border: none; 
    color: #d8b4fe; 
    width: 24px; height: 24px; 
    border-radius: 50%; 
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; 
    font-size: 0.8rem;
    transition: all 0.2s;
}
#btnCancelMode:hover { background: rgba(255, 255, 255, 0.2); color: white; transform: scale(1.1); }

/* INPUT AREA */
.input-area.stacked {
    flex-shrink: 0; background: var(--header-bg); border-top: 1px solid var(--border-color);
    padding: 10px 15px; display: flex; flex-direction: column; gap: 8px; z-index: 20;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

textarea {
    width: 100%; 
    min-height: 45px; 
    max-height: 160px; 
    background: var(--input-bg);
    color: white; border: 1px solid #333; border-radius: 20px; padding: 12px 15px;
    resize: none; outline: none; font-size: 0.95rem; 
    overflow-y: auto; 
    line-height: 1.4;
}
textarea:focus { border-color: #666; }

/* TOOLBAR & BUTTONS */
.input-toolbar { display: flex; justify-content: space-between; align-items: center; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; }
.btn-tool { background: transparent; border: none; color: #888; font-size: 1.4rem; cursor: pointer; padding: 5px; }
.btn-tool:hover { color: white; }
.magic-trigger { color: #8b5cf6; } 
.mode-badge { padding: 5px 10px; border-radius: 15px; font-size: 0.75rem; font-weight: 600; cursor: pointer; background: var(--badge-bg); color: #888; border: 1px solid transparent; }
.mode-badge.mode-pro { color: #a855f7; border-color: rgba(168, 85, 247, 0.3); }
.mode-badge.mode-fast { color: #eab308; border-color: rgba(234, 179, 8, 0.3); }
.btn-send-round { background: white; color: black; border: none; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem; transition: transform 0.1s; }
.btn-send-round:active { transform: scale(0.9); }

/* SIDEBAR & UTILS */
.sidebar { position: fixed; top: 0; left: 0; width: 280px; height: 100%; background: #181818; z-index: 10000; transform: translateX(-100%); transition: transform 0.3s; display: flex; flex-direction: column; box-shadow: 5px 0 15px rgba(0,0,0,0.5); }
.sidebar.active { transform: translateX(0); }
.sidebar-header { padding: 20px; border-bottom: 1px solid #333; display: flex; justify-content: space-between; align-items: center; }
.session-list { flex: 1; overflow-y: auto; padding: 10px; }
.session-item { padding: 12px 14px; margin-bottom: 5px; background: transparent; border-radius: 8px; cursor: pointer; color: #888; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background 0.2s; border: 1px solid transparent; }
.session-item:hover { background: #222; }
.session-item.active { background: #262626; color: white; border: 1px solid #333; }
.sidebar-footer { padding: 20px; border-top: 1px solid #333; text-align: center; }
.btn-danger, .btn-install, .btn-apk { width: 100%; padding: 12px; border-radius: 8px; cursor: pointer; margin-bottom: 10px; border: none; display: flex; justify-content: center; align-items: center; gap: 8px; color: white; text-decoration: none;}
.btn-danger { background: #3f1010; color: #ff8888; } .btn-install { background: #2563eb; } .btn-apk { background: #333; }
.dev-info a { color: #888 !important; text-decoration: none; font-size: 0.85rem; font-weight: 500; transition: color 0.2s; }
.dev-info a:hover { color: white !important; }

/* MAGIC MENU & MODALS */
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 9000; display: none; }
.overlay.active { display: block; }
.magic-menu { position: fixed; bottom: 0; left: 0; width: 100%; background: #1c1c1c; border-top-left-radius: 20px; border-top-right-radius: 20px; padding: 25px 20px; z-index: 9999; transform: translateY(110%); transition: transform 0.3s ease-out; box-shadow: 0 -5px 30px rgba(0,0,0,0.8); }
.magic-menu.active { transform: translateY(0); }
.magic-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.magic-options { display: flex; flex-direction: column; gap: 12px; }
.magic-btn { display: flex; align-items: center; gap: 15px; background: #2a2a2a; border: 1px solid #333; padding: 15px; border-radius: 12px; text-align: left; cursor: pointer; color: white; }
.magic-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.gen-icon { background: #7c3aed; color: white; } .edit-icon { background: #db2777; color: white; } .chat-icon { background: #333; color: #aaa; }

/* FILE & PREVIEW */
.hidden { display: none !important; }
.image-preview { padding: 10px; background: var(--header-bg); border-top: 1px solid var(--border-color); }
#imagePreview { height: 80px; border-radius: 8px; display: block; }
.btn-close-img { position: absolute; top: -10px; right: -10px; width: 28px; height: 28px; border-radius: 50%; border: none; background: #ef4444; color: white; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.5); z-index: 10; display: flex; align-items: center; justify-content: center;}
.preview-card { position: relative; width: fit-content; overflow: visible;} 
.file-card { display: flex; align-items: center; gap: 12px; background: #252525; padding: 12px; border-radius: 12px; margin-bottom: 10px; border: 1px solid #333; width: 100%; max-width: 300px; box-shadow: 0 4px 6px rgba(0,0,0,0.2); transition: transform 0.2s; }
.file-card:hover { background: #2a2a2a; transform: translateY(-2px); }
.file-icon-box { width: 45px; height: 45px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white; flex-shrink: 0; }
.file-info { display: flex; flex-direction: column; overflow: hidden; flex: 1; }
.file-name { font-size: 0.95rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-type { font-size: 0.75rem; color: #aaa; margin-top: 2px; }
.bg-pdf { background: #ff4757; } .bg-word { background: #2e86de; } .bg-excel { background: #10ac84; } .bg-ppt { background: #ff9f43; } .bg-img { background: #f368e0; } .bg-default { background: #57606f; }

/* WELCOME & VISITOR */
.welcome-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; width: 100%; position: absolute; top: 0; left: 0; padding: 20px; z-index: 1; pointer-events: none; text-align: center; color: var(--text-secondary); }
.animate-title { font-size: 3rem; font-weight: 900; text-transform: uppercase; background: linear-gradient(90deg, #ffffff 0%, #a855f7 25%, #3b82f6 50%, #a855f7 75%, #ffffff 100%); background-size: 200% auto; color: #fff; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: shineText 3s linear infinite; margin-bottom: 10px; display: block; text-shadow: 0 0 30px rgba(124, 58, 237, 0.3); }
@keyframes shineText { to { background-position: 200% center; } }
.ig-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; color: #d62976 !important; font-size: 0.9rem; font-weight: bold; text-decoration: none; transition: 0.2s; }
.ig-link:hover { color: #f9539b !important; text-decoration: underline; transform: translateY(-1px); }
.visitor-card { background: linear-gradient(145deg, #1a1a1a, #222); border: 1px solid #333; border-radius: 12px; padding: 15px; margin-bottom: 20px; text-align: center; position: relative; overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.visitor-card::before { content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent); animation: shine 3s infinite; }
@keyframes shine { 100% { left: 100%; } }
.visitor-count { font-size: 1.8rem; font-weight: 800; color: #fff; font-family: 'Courier New', monospace; text-shadow: 0 0 10px rgba(255,255,255,0.2); margin: 5px 0; }

/* MODAL & DIALOG */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); z-index: 20000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.3s ease-in-out; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-overlay.hidden { display: none !important; opacity: 0; pointer-events: none; }
.modal-box { background: #1e1e1e; border: 1px solid #333; padding: 25px; border-radius: 16px; width: 85%; max-width: 320px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5); transform: scale(0.9); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.modal-overlay.active .modal-box { transform: scale(1); }
.modal-icon { width: 60px; height: 60px; background: rgba(124, 58, 237, 0.1); color: #8b5cf6; border-radius: 50%; font-size: 1.8rem; display: flex; align-items: center; justify-content: center; margin: 0 auto 15px auto; }
.modal-box h3 { color: white; margin-bottom: 8px; font-size: 1.2rem; }
.modal-box p { color: #aaa; margin-bottom: 20px; font-size: 0.9rem; line-height: 1.4; }
.modal-buttons { display: flex; gap: 10px; justify-content: center; }
.btn-modal { flex: 1; padding: 10px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn-modal.secondary { background: #333; color: #ccc; } .btn-modal.secondary:hover { background: #444; color: white; }
.btn-modal.primary { background: #7c3aed; color: white; } .btn-modal.primary:hover { background: #6d28d9; }

/* AUTH MODAL */
.auth-box { width: 90%; max-width: 350px; padding: 30px; position: relative; }
.btn-close-modal { position: absolute; top: 15px; right: 15px; background: none; border: none; color: #666; font-size: 1.2rem; cursor: pointer; }
.auth-box h2 { color: white; margin-bottom: 5px; }
.auth-box p { color: #888; font-size: 0.9rem; margin-bottom: 20px; }
.input-group { position: relative; margin-bottom: 15px; }
.input-group i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #888; }
.input-group input { width: 100%; padding: 12px 15px 12px 40px; background: #2a2a2a; border: 1px solid #444; border-radius: 8px; color: white; outline: none; transition: 0.3s; }
.input-group input:focus { border-color: #a855f7; }
.auth-footer { margin-top: 15px; font-size: 0.85rem; color: #888; }
.auth-footer a { color: #a855f7; text-decoration: none; font-weight: bold; margin-left: 5px; }
.auth-footer a:hover { text-decoration: underline; }
.user-profile { display: flex; align-items: center; gap: 10px; background: #252525; padding: 10px; border-radius: 8px; margin-bottom: 15px; border: 1px solid #333; }
.avatar { width: 40px; height: 40px; background: #a855f7; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 1.2rem; }
.user-info h4 { color: white; font-size: 0.95rem; margin: 0; }
.badge-member { font-size: 0.7rem; background: rgba(16, 185, 129, 0.2); color: #10b981; padding: 2px 6px; border-radius: 4px; }

/* QUICK PROMPTS & MIC */
.quick-prompts { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 5px; white-space: nowrap; scrollbar-width: none; }
.quick-prompts::-webkit-scrollbar { display: none; }
.prompt-chip { background: #2a2a2a; color: #ccc; border: 1px solid #333; padding: 6px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 500; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.prompt-chip:hover { background: #333; color: white; border-color: #555; transform: translateY(-1px); }
.prompt-chip i { font-size: 0.8rem; color: #a855f7; }
#btnMic { transition: all 0.3s; }
#btnMic.listening { color: #ef4444; animation: pulseMic 1.5s infinite; background: rgba(239, 68, 68, 0.1); border-radius: 50%; }
@keyframes pulseMic { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); } 70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
.btn-speak { margin-left: 5px; color: #10b981; } .btn-speak:hover { color: #34d399; }
.btn-speak.speaking { color: #f59e0b; animation: shake 0.5s infinite; }
@keyframes shake { 0% { transform: rotate(0deg); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } 100% { transform: rotate(0deg); } }

/* ANIMASI LOADING */
.typing-indicator { display: flex; align-items: center; gap: 6px; padding: 6px 4px; min-height: 24px; }
.typing-indicator span { display: block; width: 8px; height: 8px; background-color: #a855f7; border-radius: 50%; animation: typingBounce 1.4s infinite ease-in-out both; }
.mode-fast .typing-indicator span { background-color: #eab308; }
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; } .typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce { 0%, 80%, 100% { transform: scale(0); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }
.temp-message .bubble { background: transparent; border: 1px solid rgba(168, 85, 247, 0.2); box-shadow: 0 0 10px rgba(168, 85, 247, 0.05); }
.generating { opacity: 0.6; cursor: wait; animation: pulse 1s infinite; }

/* FIX FINAL: SWEETALERT DI ATAS SIDEBAR */
/* Menggunakan Class langsung dengan !important tinggi */
.swal2-container {
    z-index: 100000 !important; /* Sidebar cuma 10000, ini 100000 */
}