/* ==========================================
   MONOSPACE TERMINAL MATRIX SYSTEM (0px Corners)
   ========================================== */
:root {
    --bg-main: #0a0a0c;
    --bg-sidebar: #101014;
    --panel-border: #1f1f24;
    --panel-border-active: #00ff66; /* Retro terminal glow for active states */
    --input-wrapper: #141418;
    --text-primary: #e1e1e6;
    --text-muted: #62626a;
    --user-msg-bg: #18181f;
    --radius-ui: 1px; /* Force sharp edges everywhere */
}

.light-mode {
    --bg-main: #ffffff;
    --bg-sidebar: #f4f4f6;
    --panel-border: #dbdbdf;
    --panel-border-active: #0066cc;
    --input-wrapper: #ededf0;
    --text-primary: #121214;
    --text-muted: #787880;
    --user-msg-bg: #e4e4e9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Force high-fidelity code fonts universally */
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Monaco, monospace;
}

body {
    background: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    letter-spacing: -0.2px;
}

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

/* ==========================================
   BRUTALIST OUTLINED SIDEBAR
   ========================================== */
.sidebar {
    width: 320px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    padding: 16px;
    flex-shrink: 0;
    gap: 16px;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-area h2 {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
}

.hourglass-logo {
    width: 16px;
    height: 16px;
    background: var(--text-primary);
    clip-path: polygon(0% 0%, 100% 0%, 50% 50%, 100% 100%, 0% 100%, 50% 50%);
}

.new-chat-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    border-radius: var(--radius-ui);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: left;
    text-transform: uppercase;
}

.new-chat-btn:hover {
    background: var(--input-wrapper);
    border-color: var(--text-primary);
}

/* Hardcoded System Directive Drawer */
.system-prompt-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-ui);
}

.system-prompt-panel label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
}

.system-prompt-panel textarea {
    width: 100%;
    height: 120px;
    background: var(--bg-main);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-ui);
    color: var(--text-primary);
    padding: 8px;
    font-size: 0.8rem;
    line-height: 1.4;
    resize: none;
    outline: none;
}

.system-prompt-panel textarea:focus {
    border-color: var(--panel-border-active);
}

.history-list {
    flex: 1;
    overflow-y: auto;
}

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

.footer-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 0;
    cursor: pointer;
    width: 100%;
    font-size: 0.8rem;
    text-align: left;
    text-transform: uppercase;
}

.footer-action-btn:hover {
    color: var(--text-primary);
}

/* ==========================================
   THE VIEWPORT CORE AREA
   ========================================== */
.chat-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
}

.chat-header {
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 1px solid var(--panel-border);
}

.messages-container {
    flex: 1;
    padding: 0 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.message {
    display: flex;
    gap: 16px;
    padding: 24px 0;
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    border-bottom: 1px dashed var(--panel-border);
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-ui);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

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

.user-msg .avatar {
    display: none;
}

.user-msg .msg-content {
    background: var(--user-msg-bg);
    padding: 12px 16px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-ui);
    max-width: 85%;
}

.assistant-msg .avatar {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-primary);
}

.assistant-msg .msg-content {
    padding: 4px 0;
    width: 100%;
}

.msg-content {
    font-size: 0.9rem;
    line-height: 1.6;
    word-break: break-word;
}

/* ==========================================
   INPUT SYSTEM INTEGRATION
   ========================================== */
.input-area-container {
    padding: 16px 24px 24px 24px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.image-preview-dock {
    display: flex;
    position: relative;
    width: fit-content;
    background: var(--input-wrapper);
    padding: 4px;
    border-radius: var(--radius-ui);
    margin-bottom: 8px;
    border: 1px solid var(--panel-border-active);
}

.image-preview-dock img {
    height: 50px;
    width: auto;
    border-radius: var(--radius-ui);
}

.chat-form-wrapper {
    display: flex;
    background: var(--input-wrapper);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-ui);
    padding: 4px 12px;
    align-items: center;
    gap: 12px;
}

.chat-form-wrapper:focus-within {
    border-color: var(--panel-border-active);
}

.tool-attach-btn {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-attach-btn:hover { color: var(--text-primary); }

.chat-form-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    padding: 10px 0;
    font-size: 0.9rem;
    font-family: inherit;
}

.chat-form-wrapper button[type="submit"] {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--panel-border);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-ui);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-form-wrapper button[type="submit"]:hover {
    background: var(--text-primary);
    color: var(--bg-main);
}

/* ==========================================
   TERMINAL BLOCK PARSING FRAMEWORK
   ========================================== */
.code-container-block {
    margin: 16px 0;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-ui);
    background: #000000;
    overflow: hidden;
}

.code-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #101014;
    padding: 6px 14px;
    border-bottom: 1px solid var(--panel-border);
}

.code-lang-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: bold;
    text-transform: uppercase;
}

.code-copy-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    font-size: 0.72rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: var(--radius-ui);
    text-transform: uppercase;
}

.code-copy-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.code-pre-element {
    padding: 14px;
    overflow-x: auto;
    margin: 0;
}

.code-pre-element code {
    font-size: 0.85rem;
    color: #00ff66; /* Pure retro green prompt default output color */
    line-height: 1.5;
}

.light-mode .code-pre-element code {
    color: #004411;
}