:root {
    --bg: #111;
    --surface: #1a1a1a;
    --surface2: #222;
    --border: #2e2e2e;
    --orange: #ff6a00;
    --orange2: #ff9900;
    --orange-dim: #7a3200;
    --orange-glow: rgba(255, 106, 0, 0.15);
    --text: #f5e6d0;
    --text-dim: #8a7a6a;
    --text-muted: #3a3028;
    --diamond: #4dd9e8;
    --dg: rgba(77, 217, 232, 0.2);
    --danger: #e74c3c;
    --success: #2ecc71;
    --r: 8px;
}

@import url(https://fonts.googleapis.com/css2?family=Jaro:opsz@6..72&family=Passero+One&display=swap);

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow: hidden; 
    font-family: "Passero One", sans-serif;
    font-size: 16px; 
    text-align: left; 
}

/* Animated Grid Background */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(255, 106, 0, 0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 106, 0, 0.04) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
    z-index: -1;
    animation: gridDriftX 60s ease-in-out infinite alternate, gridDriftY 43s ease-in-out infinite alternate;
}

@keyframes gridDriftX {
    0% { background-position-x: 0px; }
    100% { background-position-x: 1024px; }
}

@keyframes gridDriftY {
    0% { background-position-y: 0px; }
    100% { background-position-y: 1024px; }
}

/* --- APP LAYOUT --- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 280px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 12px;
    transition: transform 0.3s ease, width 0.3s ease;
    flex-shrink: 0;
}

.sidebar.collapsed { width: 0; padding: 0; overflow: hidden; border: none; }

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover { background: var(--surface2); color: var(--orange2); }

.new-chat-btn {
    background-color: var(--surface2);
    color: var(--orange);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 12px 16px;
    font-size: 16px;
    font-family: "Passero One", sans-serif;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin-bottom: 24px;
    transition: background 0.2s, box-shadow 0.2s;
}

.new-chat-btn:hover { background-color: var(--orange-dim); box-shadow: 0 0 10px var(--orange-glow); }
.plus-icon { font-size: 20px; line-height: 1; }

.recent-chats { flex: 1; overflow-y: auto; }
.section-title { font-size: 14px; color: var(--text-dim); margin: 0 8px 8px 8px; padding-bottom: 4px; }

.history-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; margin-bottom: 4px; border-radius: 8px;
    cursor: pointer; color: var(--text-dim); font-size: 15px;
    transition: background 0.2s, color 0.2s;
}

.history-item:hover, .history-item.active { background-color: var(--surface2); color: var(--orange2); }
.history-item-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.history-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.history-item:hover .history-actions, .history-item.active .history-actions { opacity: 1; }
.history-actions button { background: transparent; border: none; cursor: pointer; font-size: 14px; color: var(--text-dim); }
.history-actions button:hover { color: var(--orange); }

.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border); }
.nav-link { display: block; text-decoration: none; color: var(--text-dim); padding: 10px 12px; border-radius: 8px; font-size: 16px; transition: background 0.2s;}
.nav-link:hover { background-color: var(--surface2); color: var(--orange2); }
.sidebar-legal { font-size: 12px; color: var(--text-muted); padding: 12px; line-height: 1.6; }
.sidebar-legal a { color: var(--text-muted); text-decoration: none; }
.sidebar-legal a:hover { color: var(--orange2); }

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1; display: flex; flex-direction: column; position: relative; height: 100vh;
}

.top-nav { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; }
.nav-left { display: flex; align-items: center; gap: 12px; }
.brand-text { font-family: "Jaro", sans-serif; font-size: 24px; color: var(--orange2); letter-spacing: 1px; }

/* THE UPDATED AVATAR LOGO CSS */
.user-avatar {
    width: 36px; height: 36px;
    background-color: transparent; /* Removed the orange background */
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; /* Keeps the logo inside the circle */
}
.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ensures the logo shrinks to fit without distorting */
}

/* --- CHAT AREA --- */
.chat-container {
    flex: 1; display: flex; flex-direction: column; 
    max-width: 1000px; 
    margin: 0 auto; width: 100%; padding: 0 16px; position: relative;
}

.welcome-screen { 
    flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; 
    padding-bottom: 100px; display: none; text-align: center; 
}
.greeting { font-size: 48px; color: var(--orange); margin-bottom: 8px; text-shadow: 0 0 15px var(--orange-glow); }
.sub-greeting { font-size: 32px; color: var(--text-dim); }

.chat-box-body { flex: 1; overflow-y: auto; padding-bottom: 24px; display: flex; flex-direction: column; scroll-behavior: smooth; }
.chat-box-body::-webkit-scrollbar { width: 6px; }
.chat-box-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.message-wrapper { display: flex; flex-direction: column; margin-bottom: 24px; width: 100%; }
.message-wrapper.user { align-items: flex-end; }
.message-wrapper.assistant { align-items: flex-start; }

.message {
    background-color: var(--orange); color: black; padding: 12px 20px;
    border-radius: 24px; font-size: 18px; max-width: 85%;
    box-shadow: 0 4px 15px var(--orange-glow); text-align: left;
}

.response {
    color: var(--text); font-size: 18px; max-width: 100%; padding-right: 20px; text-align: left;
}

/* --- INPUT AREA --- */
.input-wrapper { padding-bottom: 16px; width: 100%; }
.input-box {
    display: flex; align-items: center; background-color: var(--surface);
    border: 1px solid var(--border); border-radius: 24px; padding: 8px 16px; gap: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); width: 100%;
}

#chat-input {
    flex: 1; background: transparent; border: none; color: var(--text);
    font-size: 18px; padding: 12px 0; outline: none; font-family: inherit; width: 100%;
}
#chat-input::placeholder { color: var(--text-muted); }
.send-btn { color: var(--orange); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.disclaimer { text-align: center; font-size: 14px; color: var(--text-muted); margin-top: 12px; }

/* --- ATTACHMENTS --- */
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.attachment-chip { background: var(--surface2); border: 1px solid var(--orange-dim); border-radius: 12px; padding: 6px 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; color: var(--orange2);}
.attachment-chip button { background: none; border: none; color: var(--danger); cursor: pointer; }

/* --- MARKDOWN --- */
.response p { margin-bottom: 12px; }
.response p:last-child { margin-bottom: 0; }
.response ul, .response ol { margin-left: 20px; margin-bottom: 12px; }
.response strong { color: var(--orange2); font-weight: normal; }
.response code { background: var(--surface2); padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 14px; }
.response pre { background: var(--surface); padding: 16px; border-radius: 12px; overflow-x: auto; margin-bottom: 16px; border: 1px solid var(--border); }
.response pre code { background: transparent; padding: 0; }

/* --- PC DASHBOARD SETTINGS PAGE --- */
.settings-container { 
    max-width: 1400px; 
    width: 100%; margin: 0 auto; padding: 30px 40px; height: 100%; overflow-y: auto; text-align: left; 
}
.settings-container h1 { font-size: 42px; color: var(--orange); margin-bottom: 30px; }

.settings-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 30px;
    align-items: start;
}

.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; }
.settings-card h2 { font-size: 24px; color: var(--orange2); margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 8px;}

.settings-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.settings-group label { font-size: 16px; color: var(--text-dim); }
.settings-group input { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 12px; border-radius: 8px; font-family: inherit; font-size: 16px; outline: none; width: 100%;}
.settings-group input:focus { border-color: var(--orange); }

.save-btn { background: var(--orange); color: black; border: none; padding: 12px 24px; border-radius: 8px; font-family: inherit; font-size: 18px; cursor: pointer; transition: 0.2s; width: max-content;}
.save-btn:hover { background: var(--orange2); box-shadow: 0 0 10px var(--orange-glow); }

.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-top: 20px; }
.usage-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.usage-card.is-exhausted { border-color: var(--danger); }
.usage-card-header { display: flex; justify-content: space-between; color: var(--text-dim); }
.usage-key { font-family: "Jaro", sans-serif; color: var(--orange2); }
.usage-card-body { font-size: 16px; display: grid; gap: 6px; }
.usage-card-footer { font-size: 14px; color: var(--text-dim); display: flex; justify-content: space-between; }
.usage-totals { grid-column: 1 / -1; background: var(--surface2); border: 1px solid var(--orange-dim); border-radius: 12px; padding: 16px; }

/* Mobile Adaptations */
@media (max-width: 768px) {
    .sidebar { position: fixed; height: 100vh; transform: translateX(-100%); z-index: 100; }
    .sidebar.open { transform: translateX(0); width: 280px; }
    .settings-container { padding: 20px; }
    .settings-dashboard { grid-template-columns: 1fr; } 
}