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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #1a1f35 0%, #0f1419 100%);
    color: #e5e7eb;
    overflow: hidden;
}

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

/* Login Overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1f35 0%, #0f1419 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.login-box h2 {
    font-size: 22px;
    font-weight: 600;
    color: #e5e7eb;
    margin-bottom: 6px;
    text-align: center;
}

.login-subtitle {
    font-size: 13px;
    color: #8b949e;
    text-align: center;
    margin-bottom: 28px;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-box input {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 14px;
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.2s;
}

.login-box input:focus {
    border-color: #58a6ff;
}

.login-box button[type="submit"] {
    background: #238636;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    padding: 10px;
    margin-top: 4px;
    transition: background 0.2s;
}

.login-box button[type="submit"]:hover {
    background: #2ea043;
}

.login-error {
    color: #f85149;
    font-size: 13px;
    text-align: center;
    min-height: 18px;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: #0d1117;
    border-right: 1px solid #30363d;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed {
    margin-left: -320px;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #30363d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #c9d1d9;
}

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

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0d1117;
}

.chat-header {
    padding: 12px 20px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 600;
    color: #58a6ff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mode-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3fb950;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.meta-text {
    font-size: 11px;
    color: #8b949e;
}

/* Chat Messages */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, #0d1117 0%, #010409 100%);
}

.chat-messages {
    max-width: 900px;
    margin: 0 auto;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #8b949e;
}

.welcome-message h2 {
    color: #58a6ff;
    margin-bottom: 12px;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.quick-action {
    padding: 10px 18px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #c9d1d9;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.quick-action:hover {
    background: #21262d;
    border-color: #58a6ff;
    transform: translateY(-2px);
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #58a6ff 0%, #1f6feb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #3fb950 0%, #2ea043 100%);
}

.message-content {
    flex: 1;
    max-width: 70%;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    background: #161b22;
    border: 1px solid #30363d;
    line-height: 1.6;
}

.message.user .message-bubble {
    background: #1f6feb;
    border-color: #1f6feb;
    color: #ffffff;
}

.message-time {
    font-size: 11px;
    color: #6e7681;
    margin-top: 4px;
    padding: 0 4px;
}

.message.user .message-time {
    text-align: right;
}

.message-code {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 13px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #58a6ff;
    animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-10px);
    }
}

/* Input Area */
.chat-input-area {
    padding: 16px 20px;
    background: #161b22;
    border-top: 1px solid #30363d;
}

.session-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #0d1117;
    border-radius: 8px;
}

.session-info {
    display: flex;
    gap: 8px;
    align-items: center;
}

.session-select {
    max-width: 240px;
}

.status-text {
    font-size: 12px;
    color: #8b949e;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: 900px;
    margin: 0 auto;
}

#chatInput {
    flex: 1;
    min-height: 44px;
    max-height: 200px;
    padding: 12px 16px;
    border: 2px solid #30363d;
    border-radius: 12px;
    background: #0d1117;
    color: #c9d1d9;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s;
}

#chatInput:focus {
    outline: none;
    border-color: #58a6ff;
}

.voice-btn,
.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.voice-btn {
    background: #21262d;
    color: #8b949e;
    position: relative;
}

.voice-btn:hover {
    background: #30363d;
    transform: scale(1.05);
}

.voice-btn.active {
    background: #da3633;
    color: white;
    animation: voicePulse 1s infinite;
}

@keyframes voicePulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(218, 54, 51, 0.7);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(218, 54, 51, 0);
    }
}

.voice-pulse {
    display: none;
}

.send-btn {
    background: linear-gradient(135deg, #1f6feb 0%, #1158c7 100%);
    color: white;
}

.send-btn:hover {
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.voice-indicator {
    text-align: center;
    padding: 12px;
    color: #8b949e;
}

.voice-wave {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #da3633;
    margin: 0 auto 8px;
    animation: voiceWave 1s infinite;
}

@keyframes voiceWave {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

/* Buttons */
input,
button,
select,
textarea {
    font-family: inherit;
}

button {
    cursor: pointer;
    border: none;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    color: #8b949e;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 16px;
}

.icon-btn:hover {
    background: #21262d;
    color: #c9d1d9;
}

.icon-btn.active {
    background: #1f6feb;
    color: white;
}

select {
    padding: 6px 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 13px;
}

select:focus {
    outline: none;
    border-color: #58a6ff;
}

.model-select {
    min-width: 120px;
}

/* File Browser */
.file-nav {
    margin-bottom: 12px;
}

.file-nav select {
    width: 100%;
    margin-bottom: 8px;
}

.path-nav {
    display: flex;
    gap: 6px;
}

.path-nav input {
    flex: 1;
    padding: 8px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #c9d1d9;
    font-size: 13px;
}

.path-nav input:focus {
    outline: none;
    border-color: #58a6ff;
}

.file-list {
    list-style: none;
    max-height: 40vh;
    overflow-y: auto;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #0d1117;
    margin-bottom: 12px;
}

.file-item {
    padding: 10px 12px;
    border-bottom: 1px solid #21262d;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    transition: background 0.15s;
}

.file-item:hover {
    background: #161b22;
}

.file-item.heading {
    background: #161b22;
    color: #8b949e;
    cursor: default;
    font-weight: 600;
    font-size: 11px;
}

.file-item.empty {
    color: #6e7681;
    cursor: default;
    font-style: italic;
}

.file-item.empty:hover {
    background: transparent;
}

.subtle {
    margin: 0 0 8px;
    color: #6e7681;
    font-size: 11px;
}

.file-preview h3 {
    font-size: 13px;
    color: #8b949e;
    margin-bottom: 8px;
}

.file-content {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 12px;
    max-height: 30vh;
    overflow: auto;
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    color: #c9d1d9;
}

/* Terminal Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(1, 4, 9, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    width: 90%;
    max-width: 1000px;
    max-height: 80vh;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #30363d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #c9d1d9;
    font-size: 16px;
}

.terminal {
    flex: 1;
    padding: 16px;
    overflow: auto;
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    color: #c9d1d9;
    background: #010409;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #0d1117;
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Responsive */
@media (max-width: 980px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
    }

    .sidebar:not(.collapsed) {
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

    .chat-header {
        flex-wrap: wrap;
        padding: 10px 12px;
    }

    .header-left h1 {
        font-size: 16px;
    }

    .mode-controls {
        gap: 6px;
    }

    .message-content {
        max-width: 85%;
    }

    .chat-messages {
        max-height: calc(100vh - 240px);
    }

    .chat-input-area {
        padding: 12px;
    }

    .session-controls {
        margin-bottom: 8px;
        padding: 6px 8px;
    }

    .session-select {
        max-width: 150px;
        font-size: 13px;
    }

    .input-wrapper {
        gap: 8px;
    }

    #chatInput {
        min-height: 40px;
        font-size: 14px;
        padding: 10px 12px;
    }

    .voice-btn,
    .send-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .meta-text {
        display: none;
    }

    .file-preview {
        max-height: 30vh;
    }
}

@media (max-width: 600px) {
    .sidebar {
        width: 280px;
    }

    .sidebar.collapsed {
        margin-left: -280px;
    }

    .chat-header {
        padding: 8px;
    }

    .header-left h1 {
        font-size: 14px;
    }

    .mode-controls {
        flex-wrap: wrap;
    }

    .model-select {
        font-size: 12px;
        padding: 4px 8px;
    }

    .session-info {
        flex-wrap: wrap;
    }

    .session-select {
        max-width: 120px;
        font-size: 12px;
    }

    .command-status {
        display: none;
    }

    #chatInput {
        min-height: 38px;
        font-size: 13px;
        padding: 8px 10px;
    }

    .voice-btn,
    .send-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .message-bubble {
        font-size: 14px;
        padding: 10px 12px;
    }

    .message-time {
        font-size: 10px;
    }

    .quick-action {
        font-size: 13px;
        padding: 8px 12px;
    }
}
