:root {
    --bg-main: #000000;
    --bg-surface: #121212;
    --bg-elevated: #262626;
    --red-gradient: linear-gradient(45deg, #ff0033, #ff4b2b);
    --red-solid: #ff0033;
    --text-primary: #ffffff;
    --text-secondary: #8e8e8e;
    --border-color: #262626;
    --font-main: 'Inter', -apple-system, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

/* === SIDEBAR (WIDENED TO 320px & SMOOTH TOGGLE) === */
.sidebar {
    width: 320px;
    min-width: 320px;
    background-color: var(--bg-main);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
    gap: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

/* Desktop Sidebar Toggle State */
.sidebar.hidden {
    margin-left: -320px;
    transform: translateX(-100%);
    opacity: 0;
}

.brand {
    display: flex;
    align-items: center;
}

.brand h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* === 3D RED GLOWING CUBE LOGO === */
.brand-logo-container {
    perspective: 800px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

.brand-cube {
    width: 24px;
    height: 24px;
    position: relative;
    transform-style: preserve-3d;
    animation: spinCube 4s infinite linear;
}

.cube-face {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(255, 0, 51, 0.15);
    border: 1px solid #ff0033;
    box-shadow: 0 0 10px #ff0033, inset 0 0 8px #ff0033;
}

.face-front  { transform: translateZ(12px); }
.face-back   { transform: rotateY(180deg) translateZ(12px); }
.face-right  { transform: rotateY(90deg) translateZ(12px); }
.face-left   { transform: rotateY(-90deg) translateZ(12px); }
.face-top    { transform: rotateX(90deg) translateZ(12px); }
.face-bottom { transform: rotateX(-90deg) translateZ(12px); }

@keyframes spinCube {
    0% { transform: rotateX(0deg) rotateY(0deg); }
    100% { transform: rotateX(360deg) rotateY(360deg); }
}

/* === NEW: LARGE CENTER 3D CUBE === */
.center-cube-container {
    perspective: 1000px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 40px auto;
    width: 100px;
    height: 100px;
}

.center-cube {
    width: 60px;
    height: 60px;
    animation: spinCube 8s infinite linear;
}

.center-cube .cube-face {
    background: rgba(255, 0, 51, 0.08);
    border: 1px solid #ff0033;
    box-shadow: 0 0 25px rgba(255, 0, 51, 0.5), inset 0 0 15px rgba(255, 0, 51, 0.6);
}

.center-cube .face-front  { transform: translateZ(30px); }
.center-cube .face-back   { transform: rotateY(180deg) translateZ(30px); }
.center-cube .face-right  { transform: rotateY(90deg) translateZ(30px); }
.center-cube .face-left   { transform: rotateY(-90deg) translateZ(30px); }
.center-cube .face-top    { transform: rotateX(90deg) translateZ(30px); }
.center-cube .face-bottom { transform: rotateX(-90deg) translateZ(30px); }

/* === GLOWING STATUS DOT === */
.core-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.glowing-dot {
    width: 10px;
    height: 10px;
    background-color: #ff0033;
    border-radius: 50%;
    box-shadow: 0 0 8px #ff0033, 0 0 15px #ff0033;
    animation: pulse-dot 1.5s infinite alternate;
}

@keyframes pulse-dot {
    0% { box-shadow: 0 0 8px #ff0033, 0 0 12px #ff0033; opacity: 0.7; }
    100% { box-shadow: 0 0 15px #ff0033, 0 0 25px #ff0033; opacity: 1; transform: scale(1.1); }
}

.status-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* === ACTION BUTTONS === */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-primary {
    background: var(--red-gradient);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary svg { width: 18px; height: 18px; }

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}
.btn-secondary:hover { background: var(--bg-elevated); transform: translateY(-1px); }
.btn-secondary:active { transform: translateY(1px); }
.btn-secondary svg { width: 18px; height: 18px; }

/* === SYSTEM MODES TOGGLE === */
.modes-section {
    transition: all 0.2s;
}

.mode-toggle:hover {
    color: white;
}

.memory-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-surface);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
}

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background: var(--red-gradient); }
input:checked + .slider:before { transform: translateX(20px); }

/* === HISTORY LIST (SPLIT SECTIONS) === */
.history-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.history-section h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.history-list { 
    display: flex; 
    flex-direction: column; 
    gap: 4px; 
    overflow-y: auto; 
    max-height: 200px;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.history-item {
    padding: 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s, color 0.2s;
}
.history-item:hover { background: var(--bg-surface); color: white; }
.history-item.active { background: var(--bg-surface); color: white; font-weight: 600; border-left: 3px solid var(--red-solid); border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* === MAIN CHAT AREA === */
.chat-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    position: relative;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

/* Universal Sidebar Toggle */
.sidebar-toggle-btn { 
    color: var(--text-secondary); 
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.sidebar-toggle-btn:hover {
    color: white;
    background: var(--bg-elevated) !important;
    border-color: var(--text-secondary) !important;
}

.mobile-menu-btn { display: none; cursor: pointer; } 
.mobile-menu-btn svg { width: 24px; color: white; }

/* === GOOGLE PROFILE AVATAR === */
.profile-avatar-btn {
    width: 40px; height: 40px;
    border-radius: 50%; overflow: hidden;
    cursor: pointer;
    border: 2px solid var(--border-color);
    transition: border-color 0.2s;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
}
.profile-avatar-btn:hover { border-color: var(--red-solid); }
.profile-avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

.chat-window {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* === EMPTY STATE & PROJECT SCREEN === */
.empty-state {
    margin: auto;
    text-align: center;
    max-width: 600px;
}

.project-screen {
    display: none; 
    flex-direction: column;
    align-items: center;
}

.project-input {
    width: 100%;
    max-width: 400px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    outline: none;
    text-align: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.project-input:focus {
    border-color: var(--red-solid);
    box-shadow: 0 0 15px rgba(255,0,51,0.2), inset 0 2px 4px rgba(0,0,0,0.5);
}

/* === ASSISTANTS GRID & VIBRANT ICONS === */
.assistants-grid {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.assistant-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s;
}

.assistant-card:hover:not(.disabled-card) { transform: translateY(-5px); }
.assistant-card:hover:not(.disabled-card) span { color: white; }

.icon-circle {
    width: 64px; height: 64px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
}
.icon-circle svg { width: 28px; height: 28px; color: white; }
.assistant-card span { font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; text-align: center; line-height: 1.3; transition: color 0.2s; }

/* Advanced Custom Gradient Backgrounds for Tools */
.code-bg { background: linear-gradient(135deg, #00C9FF, #92FE9D) !important; border:none !important; }
.pdf-bg { background: linear-gradient(135deg, #FF416C, #FF4B2B) !important; border:none !important; }
.voice-bg { background: linear-gradient(135deg, #8A2387, #E94057, #F27121) !important; border:none !important; }
.img-bg { background: linear-gradient(135deg, #f12711, #f5af19) !important; border:none !important; }
.music-bg { background: linear-gradient(135deg, #667eea, #764ba2) !important; border:none !important; }

/* === MESSAGES === */
.message { 
    max-width: 75%; 
    padding: 14px 18px; 
    border-radius: 20px; 
    font-size: 0.95rem; 
    line-height: 1.5; 
    animation: fadeIn 0.3s ease; 
    word-wrap: break-word;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.user-msg {
    align-self: flex-end;
    background: var(--red-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-msg {
    align-self: flex-start;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: white;
    border-bottom-left-radius: 4px;
}

.message pre {
    background: #0a0a0a;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    color: #e0e0e0;
}

/* === INSTAGRAM MODERN 3D INPUT PILL === */
.input-area {
    padding: 15px 24px 25px 24px;
    background: linear-gradient(to top, var(--bg-main) 70%, transparent);
}

.insta-3d-pill {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: rgba(30, 30, 30, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.1);
    border-radius: 40px; 
    padding: 8px 12px;
    gap: 12px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.icon-btn {
    background: none; border: none; color: var(--text-secondary);
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: color 0.2s, background 0.2s;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { color: white; background: rgba(255,255,255,0.1); }
.voice-trigger-btn:hover { color: #ff0033; }

#user-input {
    flex-grow: 1; background: none; border: none; color: white;
    font-size: 1.05rem; font-family: var(--font-main); outline: none; padding: 0 5px; width: 100%;
}
#user-input::placeholder { color: #666; }

.send-btn {
    background: var(--red-gradient); border: none; color: white; width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 4px 15px rgba(255,0,51,0.3);
}
.send-btn svg { width: 20px; height: 20px; }
.send-btn:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(255,0,51,0.5); }

/* === ATTACHMENT MENU === */
.attachment-wrapper { position: relative; }
.upload-menu {
    position: absolute; bottom: 55px; left: 0;
    background: rgba(30, 30, 30, 0.9); backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 8px; display: none; flex-direction: column; gap: 4px;
    min-width: 130px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.upload-menu.show { display: flex; }
.upload-menu button {
    background: none; border: none; color: white; padding: 12px;
    text-align: left; border-radius: 8px; cursor: pointer; font-size: 0.9rem; transition: background 0.2s;
}
.upload-menu button:hover { background: rgba(255,255,255,0.1); }

/* === SIRI PROCESSING ORB & TEXT === */
.siri-orb-container {
    display: none; 
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 120px;
    margin: 10px 0;
    gap: 15px;
}
.siri-orb-container.active { display: flex; }

.siri-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
    animation: pulse-text 1.5s infinite;
}

@keyframes pulse-text { 
    0% { opacity: 0.5; } 
    50% { opacity: 1; } 
    100% { opacity: 0.5; } 
}

.siri-orb {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ff4b2b, #ff0033);
    box-shadow: 0 0 30px #ff0033, inset 0 0 10px rgba(255,255,255,0.5);
    animation: pulsate 2s infinite ease-in-out, morph 3s infinite linear;
}

@keyframes pulsate {
    0% { transform: scale(0.9); box-shadow: 0 0 15px #ff0033; }
    50% { transform: scale(1.1); box-shadow: 0 0 40px #ff4b2b, 0 0 80px #ff0033; }
    100% { transform: scale(0.9); box-shadow: 0 0 15px #ff0033; }
}

@keyframes morph {
    0% { border-radius: 50%; }
    50% { border-radius: 40% 60% 45% 55% / 55% 45% 60% 40%; }
    100% { border-radius: 50%; }
}

/* === MOBILE & ANDROID RESPONSIVENESS === */
@media screen and (max-width: 768px) {
    .app-container {
        position: relative;
        overflow: hidden;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        height: 100%;
        width: 85%;
        max-width: 320px;
        z-index: 2000;
        box-shadow: 5px 0 25px rgba(0,0,0,0.8);
        transform: translateX(0);
        margin-left: 0;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar.active { left: 0; }
    
    /* Reset desktop hidden logic so mobile functions smoothly */
    .sidebar.hidden {
        margin-left: 0;
        left: -100%;
        opacity: 1; 
    }

    .mobile-menu-btn { display: block; }
    
    .chat-main { 
        width: 100vw; 
    }
    
    .chat-window {
        padding-bottom: 20px;
    }
    
    .message {
        max-width: 90%; 
    }
    
    .input-area {
        padding: 10px 15px calc(15px + env(safe-area-inset-bottom));
    }
}