:root {
    --bg-main: #131314;
    --bg-sidebar: #1e1f20;
    --bg-input: #1e1f20;
    --text-main: #e3e3e3;
    --text-dim: #b4b4b4;
    --accent-blue: #8ab4f8;
    --accent-purple: #c58af9;
    --border-color: #333333;
    --hover-color: #2b2c2d;
    --sidebar-width: 280px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
}

h1, h2, h3, .logo span {
    font-family: 'Outfit', sans-serif;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
    padding-left: 5px;
}

.logo-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(45deg, #4285f4, #9b72cb, #d96570);
    border-radius: 50%;
    animation: pulse 4s infinite alternate;
}

.logo span {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 15px;
    border-radius: 25px;
    border: none;
    background-color: #2b2c2d;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background-color: #37393b;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.history-label {
    font-size: 12px;
    color: var(--text-dim);
    margin: 20px 0 10px 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.history-item {
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s;
}

.history-item:hover {
    background-color: var(--hover-color);
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 32px;
    height: 32px;
    background-color: #5c5e60;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.chat-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 18px;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
}

.sidebar-toggle:hover {
    background-color: var(--hover-color);
}

.current-model {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
}

.current-model:hover {
    background-color: var(--hover-color);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 60px;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.welcome-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding-bottom: 100px;
}

.welcome-screen h1 {
    font-size: 56px;
    background: linear-gradient(to right, #4285f4, #9b72cb, #d96570);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.welcome-screen p {
    font-size: 24px;
    color: var(--text-dim);
    margin-bottom: 40px;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    width: 100%;
}

.card {
    background-color: var(--bg-sidebar);
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 140px;
}

.card:hover {
    background-color: #2b2c2d;
    transform: translateY(-2px);
}

.card i {
    font-size: 24px;
    color: var(--accent-blue);
}

.card span {
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.4;
}

/* Chat Messages */
.message {
    margin-bottom: 30px;
    display: flex;
    gap: 20px;
    animation: fadeIn 0.4s ease;
}

.message-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-icon {
    background-color: #5c5e60;
}

.message.ai .message-icon {
    background: linear-gradient(45deg, #4285f4, #9b72cb);
}

.message-content {
    font-size: 16px;
    line-height: 1.6;
    padding-top: 6px;
}

.message-content pre {
    background-color: #2b2c2d;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    overflow-x: auto;
}

.message-content code {
    font-family: 'Consolas', monospace;
    font-size: 14px;
}

.trace-link {
    margin-top: 10px;
    display: inline-block;
    color: var(--accent-blue);
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
}

.trace-link:hover {
    text-decoration: underline;
}

/* Input Area */
.input-container {
    padding: 20px 60px 40px;
    background-color: var(--bg-main);
}

.input-wrapper {
    background-color: var(--bg-input);
    border-radius: 32px;
    padding: 12px 24px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: #444;
}

#user-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 16px;
    padding: 8px 0;
    resize: none;
    outline: none;
    max-height: 200px;
    font-family: inherit;
}

.input-actions {
    display: flex;
    gap: 5px;
    padding-bottom: 5px;
}

.send-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.send-btn:not(:disabled) {
    color: var(--accent-blue);
}

.send-btn:not(:disabled):hover {
    background-color: #2b2c2d;
}

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

/* Trace Drawer */
.trace-drawer {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.trace-drawer.open {
    right: 0;
}

.trace-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.trace-header h3 {
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
}

.trace-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.trace-item {
    margin-bottom: 20px;
}

.trace-item label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 5px;
    font-weight: 600;
}

.trace-value {
    font-family: 'Consolas', monospace;
    font-size: 13px;
    background-color: #131314;
    padding: 10px;
    border-radius: 6px;
    word-break: break-all;
}

.decision-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}

.decision-badge.ALLOW { background-color: #0d3d1e; color: #81c995; }
.decision-badge.BLOCK { background-color: #3b1111; color: #f28b82; }
.decision-badge.REDACT { background-color: #3b2b11; color: #fdd663; }

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); filter: blur(0px); }
    100% { transform: scale(1.1); filter: blur(1px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 24px;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-dim);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .messages-container {
        padding: 20px;
    }
    .input-container {
        padding: 20px;
    }
    .welcome-screen h1 {
        font-size: 36px;
    }
    .trace-drawer {
        width: 100%;
        right: -100%;
    }
}
