* {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #000;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    font-size: 12px;
    text-align: center;
    z-index: 1000;
    transition: background-color 0.3s;
}

#status.connecting {
    background: #F44336;
    background: radial-gradient(circle,rgba(244, 67, 54, 1) 0%, rgba(222, 46, 33, 1) 100%);
    color: #fff;
}

#status.connected {
    background-color: #EEAECA;
    background: radial-gradient(circle, rgba(238, 174, 202, 1) 0%, rgba(148, 187, 233, 1) 100%);
    color: #000;
}

#status.disconnected {
    background: #F44336;
    background: radial-gradient(circle,rgba(244, 67, 54, 1) 0%, rgba(222, 46, 33, 1) 100%);
    color: #fff;
}

#terminal-container {
    position: absolute;
    top: 0px;
    left: 0;
    right: 0;
    bottom: 94px;
    padding: 8px;
}

#terminal {
    width: 100%;
    height: 100%;
}

#terminal-shell-container {
    position: absolute;
    top: 0px;
    left: 0;
    right: 0;
    bottom: 94px;
    padding: 8px;
}

#terminal-shell {
    width: 100%;
    height: 100%;
}

.xterm {
    height: 100%;
    padding: 8px;
}

.xterm-viewport {
    overflow-y: auto;
    background-color: #000;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* Views */
.view {
    display: none;
    position: absolute;
    top: 31px;
    left: 0;
    right: 0;
    bottom: 50px;
    overflow: hidden;
}

.view.active {
    display: block;
}

/* Placeholder view styling */
.placeholder-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 16px;
    color: #888;
}

.placeholder-view h2 {
    color: #fff;
    margin-bottom: 16px;
    font-size: 18px;
}

.placeholder-section {
    flex: 1;
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Bottom Navigation */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: #1a1a1a;
    display: flex;
    border-top: 1px solid #333;
    z-index: 1000;
}

.nav-btn {
    flex: 1;
    background: none;
    border: none;
    color: #888;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:active {
    background: #222;
}

.nav-btn.active {
    color: #fff;
    background: #333;
}

/* Keyboard Toolbar */
#keyboard-toolbar {
    position: fixed;
    bottom: 50px;
    left: 0;
    right: 0;
    height: 88px;
    background: #2a2a2a;
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 4px 8px;
    border-top: 1px solid #444;
    z-index: 999;
}

#keyboard-toolbar.visible {
    display: flex;
}

.keyboard-row {
    display: flex;
    gap: 4px;
    flex: 1;
}

.key-btn {
    flex: 1;
    background: #3a3a3a;
    border: 1px solid #555;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 36px;
    transition: background 0.2s, border-color 0.2s;
}

.key-btn:active,
.key-btn.active {
    background: #555;
    transform: scale(0.95);
}

/* Arrow buttons - half width */
.key-btn.arrow-btn {
    flex: 0.5;
}

/* Code View Panels */
.code-panel {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

.code-panel.active {
    display: flex;
    flex-direction: column;
}

/* Code View Header */
.code-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    gap: 12px;
    position: relative;
    z-index: 101;
}

.code-header-title {
    flex: 1;
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.code-back-btn {
    background: #333;
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.code-select-toggle {
    background: #333;
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.code-select-toggle.active {
    background: #4a90d9;
    color: #fff;
}

.code-select-toggle:active {
    background: #444;
}

.code-select-toggle.active:active {
    background: #3a7fc8;
}

/* Commit Input (inline in git-commit-bar) */
.commit-input {
    width: 100%;
    box-sizing: border-box;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    padding: 8px 12px;
    resize: vertical;
    outline: none;
    margin-bottom: 12px;
    min-height: 36px;
    max-height: 120px;
}

.commit-input:focus {
    border-color: #c87699;
}

.commit-input::placeholder {
    color: #666;
}

/* File Explorer */
#file-explorer-panel {
    background: #0d0d0d;
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #222;
    cursor: pointer;
    gap: 12px;
}

.file-item:active {
    background: #222;
}

.file-icon {
    font-size: 18px;
}

.file-name {
    flex: 1;
    font-size: 14px;
    color: #fff;
}

.file-size {
    font-size: 12px;
    color: #666;
}

.file-item.has-unstaged-changes .file-name {
    color: #ffb6c1;
}

.file-item.is-ignored .file-name {
    color: #888888;
}

/* Code Viewer */
#code-viewer-panel {
    background: #0d1117;
}

.code-content {
    flex: 1;
    overflow: auto;
    padding: 0;
    position: relative;
}

.code-content pre {
    margin: 0;
    padding: 16px;
    font-size: 13px;
    line-height: 1.5;
    background: transparent !important;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.code-content code {
    background: transparent !important;
}

/* Code line selection */
#code-content-diff.select-mode .d2h-code-line-ctn {
    cursor: pointer;
}

#code-content-diff.select-mode .d2h-code-line-ctn:active {
    background: rgba(74, 144, 217, 0.2) !important;
}

#code-content-diff .d2h-code-line-ctn.selected {
    background: rgba(74, 144, 217, 0.3) !important;
}

/* Send to LLM floating button */
.send-to-llm-btn {
    display: none;
    position: fixed;
    right: 20px;
    background: #c87699;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: background 0.2s;
}

.send-to-llm-btn:active {
    background: #b5668a;
}

/* Git View Container */
.git-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Git Section (Accordion) */
.git-section {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #333;
}

.git-section:has(.git-section-content:not(.collapsed)) {
    flex: 1 1 auto;
    overflow: hidden;
}

.git-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #1a1a1a;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.git-section-header:active {
    background: #222;
}

.git-section-header.collapsed {
    border-bottom: 1px solid #333;
}

.git-section-icon {
    font-size: 12px;
    color: #888;
    transition: transform 0.2s;
}

.git-section-header.collapsed .git-section-icon {
    transform: rotate(-90deg);
}

.git-section-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.git-section-btn {
    font-size: 14px;
    color: #ccc;
    background: #444;
    padding: 9px;
    width: 120px;
    border-radius: 3px;
    border: none;
    cursor: pointer;
    margin-right: 8px;
    -webkit-tap-highlight-color: transparent;
}

.git-section-btn:active {
    background: #555;
}

.git-section-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.git-section-count {
    font-size: 12px;
    color: #888;
    background: #333;
    padding: 2px 8px;
    border-radius: 12px;
}

.git-section-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.git-section-content.collapsed {
    display: none;
}

/* File Change Item */
.git-file-item {
    padding: 12px 16px;
    border-bottom: 1px solid #222;
}

.git-file-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.git-file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.git-file-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    font-family: 'Monaco', 'Menlo', monospace;
}

.git-file-stats {
    font-size: 11px;
    color: #666;
}

.git-file-stats .added {
    color: #4caf50;
}

.git-file-stats .removed {
    color: #f44336;
}

/* Diff Display */
.git-diff {
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    margin-bottom: 8px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 11px;
    overflow-x: auto;
}

.git-diff-line {
    padding: 2px 8px;
    white-space: pre;
    line-height: 1.4;
}

.git-diff-line.added {
    background: #0d3d1f;
    color: #e8e8e8;
}

.git-diff-line.removed {
    background: #3d0d0d;
    color: #e8e8e8;
}

.git-diff-line.context {
    color: #ccc;
}

.git-diff-line.untracked {
    color: #ccc;
    background: transparent;
}

/* Diff prefix styling */
.diff-prefix {
    opacity: 0.7;
    margin-right: 4px;
}

/* Syntax highlighting overrides for all diff lines */
.git-diff-line .hljs-keyword {
    color: #c678dd;
    font-weight: 600;
}

.git-diff-line .hljs-string,
.git-diff-line .hljs-attr {
    color: #98c379;
}

.git-diff-line .hljs-number,
.git-diff-line .hljs-literal {
    color: #d19a66;
}

.git-diff-line .hljs-comment {
    color: #5c6370;
    font-style: italic;
}

.git-diff-line .hljs-function,
.git-diff-line .hljs-title {
    color: #61afef;
}

.git-diff-line .hljs-variable,
.git-diff-line .hljs-property {
    color: #e06c75;
}

.git-diff-line .hljs-type,
.git-diff-line .hljs-class {
    color: #e5c07b;
}

.git-diff-line .hljs-operator,
.git-diff-line .hljs-punctuation {
    color: #abb2bf;
}

.git-diff-line .hljs-tag,
.git-diff-line .hljs-name {
    color: #e06c75;
}

.git-diff-line .hljs-built_in,
.git-diff-line .hljs-builtin-name {
    color: #56b6c2;
}

.git-diff-line .hljs-meta {
    color: #61afef;
}

/* Enhanced syntax colors for added lines with green background */
.git-diff-line.added .hljs-keyword {
    color: #d89ff5;
}

.git-diff-line.added .hljs-string,
.git-diff-line.added .hljs-attr {
    color: #b4e89c;
}

.git-diff-line.added .hljs-number {
    color: #e5c07b;
}

.git-diff-line.added .hljs-function,
.git-diff-line.added .hljs-title {
    color: #7ec8ff;
}

.git-diff-line.added .hljs-comment {
    color: #7a8089;
}

/* Enhanced syntax colors for removed lines with red background */
.git-diff-line.removed .hljs-keyword {
    color: #d89ff5;
}

.git-diff-line.removed .hljs-string,
.git-diff-line.removed .hljs-attr {
    color: #b4e89c;
}

.git-diff-line.removed .hljs-number {
    color: #e5c07b;
}

.git-diff-line.removed .hljs-function,
.git-diff-line.removed .hljs-title {
    color: #7ec8ff;
}

.git-diff-line.removed .hljs-comment {
    color: #7a8089;
}

/* Action Buttons */
.git-file-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.git-action-btn {
    padding: 4px 12px;
    border: none;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.git-action-btn.stage {
    background: #555;
    color: #fff;
}

.git-action-btn.stage:active {
    background: #666;
}

.git-action-btn.unstage {
    background: #555;
    color: #fff;
}

.git-action-btn.unstage:active {
    background: #666;
}

.git-action-btn.discard {
    background: #c77;
    color: #fff;
}

.git-action-btn.discard:active {
    background: #b66;
}

.git-action-btn.discard.confirm {
    background: #d88;
    animation: pulse 0.5s;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Commit Bar */
.git-commit-bar {
    padding: 12px 16px;
    background: #1a1a1a;
    border-top: 1px solid #333;
}

.git-commit-btn {
    width: 100%;
    padding: 12px 24px;
    background: #c87699;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.git-commit-btn:active {
    background: #444;
}

.git-commit-btn:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

/* Pull/Push Buttons Container */
.git-sync-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.git-sync-btn {
    flex: 1;
    padding: 10px 24px;
    background: #555;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.git-sync-btn:active {
    background: #666;
}

.git-sync-btn:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
}

/* Loading State */
.git-loading {
    padding: 24px 16px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

/* Empty State */
.git-empty {
    padding: 24px 16px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

/* ===== diff2html Dark Theme Overrides ===== */

#code-content-diff {
    flex: 1;
    overflow: auto;
    background: #0d1117;
}

/* Override diff2html backgrounds for dark theme */
#code-content-diff .d2h-wrapper {
    background: #0d1117;
    width: 100%;
    overflow-x: hidden;
}

#code-content-diff .d2h-file-wrapper {
    border: none;
    background: #0d1117;
    margin-bottom: 0;
    width: 100%;
    overflow-x: hidden;
}

#code-content-diff .d2h-file-header {
    display: none;
}

/* Hide the @@ hunk info lines */
#code-content-diff .d2h-info {
    display: none;
}

#code-content-diff .d2h-diff-table {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    width: 100%;
    table-layout: fixed;
}

/* Hide line numbers completely */
#code-content-diff .d2h-code-linenumber {
    display: none !important;
}

#code-content-diff .d2h-code-side-linenumber {
    display: none !important;
}

/* Hide diff line prefixes (+/-) */
#code-content-diff .d2h-code-line-prefix {
    display: none !important;
}

/* Reset inner element backgrounds to transparent */
#code-content-diff .d2h-code-line,
#code-content-diff .d2h-code-line-ctn {
    background: transparent !important;
}

/* Ensure table cells don't cause horizontal overflow */
#code-content-diff td {
    max-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Added lines - green background on td cells */
#code-content-diff td.d2h-ins {
    background-color: rgba(46, 160, 67, 0.15) !important;
}

/* Removed lines - red background on td cells */
#code-content-diff td.d2h-del {
    background-color: rgba(248, 81, 73, 0.15) !important;
}

/* Context lines - normal background */
#code-content-diff td.d2h-cntx {
    background-color: #0d1117 !important;
}

/* Text color for all lines */
#code-content-diff .d2h-code-line {
    color: #c9d1d9;
}

/* Inline change highlights */
#code-content-diff .d2h-ins .d2h-code-line-ctn ins {
    background-color: rgba(46, 160, 67, 0.4);
    text-decoration: none;
}

#code-content-diff .d2h-del .d2h-code-line-ctn del {
    background-color: rgba(248, 81, 73, 0.4);
    text-decoration: none;
}

/* Empty diff placeholder */
#code-content-diff .d2h-file-diff .d2h-info {
    background: #161b22;
    color: #8b949e;
}

/* Special case CSS for unchanged files - REMOVED (no longer needed without line numbers) */

/* Text-wrapping in the file view - apply to all code content */
#code-content-diff .d2h-code-line-ctn,
span.d2h-code-line-ctn.hljs {
    white-space: pre-wrap !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Remove unnecessary paddings/margins to prevent horizontal scrolling */
.d2h-code-line {
    padding-left: 8px;
    padding-right: 8px;
    width: 100%;
    box-sizing: border-box;
}

/* Mobile optimizations for diff view */
@media (max-width: 600px) {
    #code-content-diff .d2h-diff-table {
        font-size: 11px;
    }

    #code-content-diff .d2h-code-linenumber {
        min-width: 30px;
        padding: 0 4px;
    }
}

/* ==================== Toast Notifications ==================== */

#toast-container {
    position: fixed;
    bottom: 60px; /* Above bottom nav (50px) with 10px clearance */
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* Allow clicks through container */
}

.toast {
    background: rgba(26, 26, 26, 0.95);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 14px 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    pointer-events: auto; /* Toast itself can be clicked */

    /* Slide up animation */
    animation: toast-slide-up 0.3s ease-out;
}

.toast.success {
    border-left: 4px solid #4CAF50; /* Green accent */
}

.toast.error {
    border-left: 4px solid #F44336; /* Red accent */
    background: rgba(244, 67, 54, 0.15);
}

@keyframes toast-slide-up {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.toast.hiding {
    animation: toast-fade-out 0.3s ease-out forwards;
}

@keyframes toast-fade-out {
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}
