﻿/* ===== REPAIR MODE STRUCTURE ===== */

html, body {
    height: 100%;
}

    body.repair-mode {
        overflow: hidden;
    }

        body.repair-mode .app__main {
            display: flex;
            flex-direction: column;
            height: 100vh;
        }

#cp-repair-mode {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.repair-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
}

.repair-title {
    font-weight: 600;
    font-size: 14px;
    text-align: center;
}

/* ===== TOP TWO-COLUMN LAYOUT ===== */

.repair-body {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0;
    min-height: 0;
    padding: 20px 20px 16px 20px;
    overflow: hidden;
}

.repair-editor-panel,
.repair-output {
    min-width: 0;
    min-height: 0;
    height: 100%;
    border: 1px solid #374151;
    background: #020617;
    overflow: hidden;
}

.repair-editor-panel {
    display: flex;
    flex-direction: column;
    border-radius: 12px 0 0 12px;
}

.repair-output {
    display: flex;
    flex-direction: column;
    border-radius: 0 12px 12px 0;
    border-left: none;
}

.repair-editor-tab {
    height: 46px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    border-bottom: 1px solid #1f2937;
    background: #080f1d;
    color: #cbd5e1;
    font-size: 13px;
}

    .repair-editor-tab span {
        color: #60a5fa;
        font-weight: 700;
    }

    .repair-editor-tab strong {
        font-size: 14px;
    }

#repairEditor {
    width: 100%;
    flex: 1 1 0;
    height: auto;
    min-height: 0;
    border: none;
    border-radius: 0;
}

#repairResizeHandle {
    display: none;
}

/* ===== BUILD OUTPUT ===== */

.repair-output-header {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    border-bottom: 1px solid #1f2937;
}

.repair-output-title {
    padding: 0;
    border-bottom: none;
    font-size: 20px;
    font-weight: 700;
    color: #f8fafc;
}

.repair-copy-btn {
    height: 42px;
    padding: 0 18px;
    border-radius: 10px;
    border: 1px solid #374151;
    background: #111827;
    color: #f8fafc;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

    .repair-copy-btn:hover {
        background: #1f2937;
        border-color: #64748b;
    }

    .repair-copy-btn:active {
        transform: translateY(1px);
    }

    .repair-copy-btn.copy-success {
        background: #166534;
        border-color: #22c55e;
        color: #ffffff;
    }

#repairErrors {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    font-family: monospace;
    font-size: 12px;
}

/* ===== ACTION AREA ===== */

.repair-actions {
    flex: 0 0 auto;
    width: calc(100% - 40px);
    margin: 0 auto;
    padding: 0 0 18px 0;
}

.repair-main-actions {
    display: grid;
    grid-template-columns: 2fr 0.9fr 0.9fr 0.9fr;
    gap: 16px;
}

.repair-action-card {
    position: relative;
    min-height: 90px;
    padding: 10px 15px;
    border-radius: 12px;
    border: 1px solid #374151;
    background: linear-gradient(180deg, #111827, #0b1220);
    color: #f8fafc;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

    .repair-action-card:hover {
        border-color: #64748b;
        background: linear-gradient(180deg, #172033, #0f172a);
    }

    .repair-action-card:active {
        transform: translateY(1px);
    }

    .repair-action-card:disabled,
    .repair-small-card:disabled,
    .algo-btn-disabled,
    .btn-disabled {
        opacity: 0.45;
        pointer-events: none;
        cursor: not-allowed;
    }

.repair-action-primary {
    border-color: #8b5cf6;
    background: linear-gradient(135deg, #7c3aed, #4c1d95);
}

    .repair-action-primary:hover {
        border-color: #a78bfa;
        background: linear-gradient(135deg, #8b5cf6, #5b21b6);
    }

.repair-card-icon {
    font-size: 32px;
    line-height: 1;
    flex: 0 0 auto;
}

.repair-card-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

    .repair-card-text strong {
        font-size: 18px;
        font-weight: 500;
        margin-bottom: 8px;
        color: #ffffff;
    }

    .repair-card-text small {
        font-size: 14px;
        line-height: 1.45;
    }

.repair-attempts {
    width: 150px;
    flex: 0 0 150px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #f8fafc;
    cursor: default;
}

    .repair-attempts span {
        font-size: 13px;
        color: #ddd6fe;
    }

    .repair-attempts select {
        height: 42px;
        border-radius: 10px;
        border: 1px solid rgba(255,255,255,0.25);
        background: rgb(15 23 41);
        color: #ffffff;
        padding: 0 12px;
        font-size: 14px;
        font-weight: 700;
    }

    .repair-attempts em {
        align-self: flex-start;
        padding: 5px 12px;
        border-radius: 999px;
        background: rgba(255,255,255,0.14);
        font-size: 12px;
        font-style: normal;
        font-weight: 700;
        color: #ffffff;
    }

/* Download Algo enabled state */
#repairDownloadBtn.algo-btn-enabled {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
    border-color: rgba(34, 197, 94, 0.75);
    color: #dcfce7;
}

    #repairDownloadBtn.algo-btn-enabled:hover {
        border-color: #22c55e;
        background: rgba(22, 101, 52, 0.34);
    }

    #repairDownloadBtn.algo-btn-enabled .repair-card-icon {
        color: #22c55e;
    }

    #repairDownloadBtn.algo-btn-enabled .repair-card-text strong {
        color: #dcfce7;
    }

    #repairDownloadBtn.algo-btn-enabled .repair-card-text small {
        color: #bbf7d0;
    }

/* ===== MORE ACTIONS ===== */

.repair-more-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 18px 0 14px;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

    .repair-more-divider::before,
    .repair-more-divider::after {
        content: "";
        flex: 1;
        height: 1px;
        background: #1f2937;
    }

.repair-secondary-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 220px 280px;
    gap: 16px;
    align-items: center;
}

.repair-small-card {
    height: 64px;
    padding: 0 20px;
    border-radius: 10px;
    border: 1px solid #374151;
    background: #111827;
    color: #f8fafc;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: flex-start;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

    .repair-small-card:hover {
        border-color: #64748b;
        background: #1f2937;
    }

    .repair-small-card:active {
        transform: translateY(1px);
    }

    .repair-small-card > span:first-child {
        font-size: 24px;
        line-height: 1;
    }

    .repair-small-card strong {
        display: block;
        color: #ffffff;
        font-size: 15px;
        margin-bottom: 3px;
        text-align: left;
        font-weight: 600;
    }

    .repair-small-card small {
        display: block;
        color: #cbd5e1;
        font-size: 12px;
        line-height: 1.25;
    }

.stop-btn {
    border-color: #f59e0b;
    background: #111827;
    color: #f8fafc;
}

.stop-btn:hover {
    background: #3a2d1a;
    border-color: #f59e0b;
}

.stop-btn:disabled {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
    border-color: #374151;
    background: #111827;
    color: #94a3b8;
}

.repair-video-link {
    color: #f8fafc;
}

.repair-exit-btn,
#exitRepairMode {
    justify-self: end;
    width: 280px;
    height: 64px;
    padding: 0 30px;
    border-radius: 10px;
    border: 1px solid #dc2626;
    background: #dc2626;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

    .repair-exit-btn:hover,
    #exitRepairMode:hover {
        background: #b91c1c;
        border-color: #b91c1c;
    }

    .repair-exit-btn:active,
    #exitRepairMode:active {
        transform: translateY(1px);
    }

    .repair-exit-btn:focus,
    #exitRepairMode:focus {
        outline: none;
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.35);
    }

/* ===== INFO STRIP ===== */

.repair-info-strip {
    margin-top: 26px;
    padding: 16px 18px;
    border-radius: 10px;
    border: 1px solid rgba(59,130,246,.3);
    background: rgba(59,130,246,.08);
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.45;
    display: flex;
    align-items: center;
    gap: 16px;
}

    .repair-info-strip strong {
        white-space: nowrap;
    }

    .repair-info-strip span {
        color: #cbd5e1;
    }

/* ===== HIDE NORMAL CHAT UI ===== */

body.repair-mode #input-area {
    display: none !important;
}

body.repair-mode #chat {
    display: none !important;
}

/* ===== BUILD OUTPUT ITEMS ===== */

.build-error-item {
    padding: 10px 12px;
    border-bottom: 1px solid #1f2937;
}

.build-error-header {
    font-weight: 600;
    font-size: 12px;
    color: #ef4444;
    display: flex;
    justify-content: space-between;
}

.error-code {
    background: #7f1d1d;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    color: #fff;
}

.build-error-message {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.4;
}

.repair-hint {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 8px;
    white-space: nowrap;
}

    .repair-hint kbd {
        padding: 2px 6px;
        border-radius: 4px;
        background: rgb(136 141 134 / 43%);
        font-size: 10px;
    }

/* ===== BUILD STATUS MESSAGES ===== */

.build-working,
.build-warning,
.build-success {
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 12px;
}

.build-working {
    background: #1f2a37;
    border: 1px solid #2f4057;
    color: #cfe3ff;
}

.build-warning {
    background: #3a2d1a;
    border: 1px solid #6a4b1e;
    color: #ffd89a;
}

.build-success {
    background: rgba(22, 101, 52, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.45);
}

.build-success-hint {
    margin-top: 8px;
    font-size: 12px;
    opacity: 0.8;
}

.build-warning::before {
    content: "⚠ ";
}

.build-working::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 8px;
    border: 2px solid #7fb8ff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: repairSpin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes repairSpin {
    to {
        transform: rotate(360deg);
    }
}

.build-info-repair {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    font-size: 13px;
    line-height: 1.4;
}

/* ===== OUTPUT MODE TOGGLE ===== */

.repair-output-mode {
    display: flex;
    align-items: center;
    margin-left: 6px;
}

.repair-mode-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.85;
    cursor: pointer;
}

    .repair-mode-toggle input {
        cursor: pointer;
    }

#devModeIndicator {
    margin-left: 10px;
    font-size: 12px;
    color: #f59e0b;
}

/* ===== LIGHT THEME ===== */

body.light .repair-editor-panel,
body.light .repair-output,
body.light .repair-action-card,
body.light .repair-small-card,
body.light .repair-copy-btn {
    background: #f3f4f6;
    color: #111827;
}

body.light .repair-editor-tab,
body.light .repair-output-header {
    background: #e5e7eb;
    border-color: #cbd5e1;
}

body.light .repair-output-title,
body.light .repair-card-text strong,
body.light .repair-small-card strong {
    color: #111827;
}

body.light .repair-card-text small,
body.light .repair-small-card small,
body.light .repair-info-strip span {
    color: #475569;
}

body.light .repair-action-primary {
    background: linear-gradient(135deg, #7c3aed, #4c1d95);
    color: #ffffff;
}

    body.light .repair-action-primary .repair-card-text strong,
    body.light .repair-action-primary .repair-card-text small {
        color: #ffffff;
    }

/* ===== RESPONSIVE ===== */

@media (max-width: 1300px) {
    .repair-body {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .repair-editor-panel,
    .repair-output {
        height: 360px;
        border-radius: 12px;
        border: 1px solid #374151;
    }

    .repair-output {
        margin-top: 16px;
    }

    .repair-main-actions {
        grid-template-columns: 1fr 1fr;
    }

    .repair-secondary-actions {
        grid-template-columns: 1fr 1fr;
    }

    .repair-exit-btn,
    #exitRepairMode {
        width: 100%;
    }
}

@media (max-width: 850px) {
    .repair-body {
        padding: 14px;
    }

    .repair-actions {
        width: calc(100% - 28px);
    }

    .repair-main-actions,
    .repair-secondary-actions {
        grid-template-columns: 1fr;
    }

    .repair-action-card {
        min-height: 100px;
    }

    .repair-action-primary {
        flex-direction: column;
        align-items: flex-start;
    }

    .repair-attempts {
        width: 100%;
        flex: none;
    }

    .repair-info-strip {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }
}
