/* =====================================================
   ai.css — the AI chat + code panel styles
   Formerly injected at runtime by ai.js as <style id="ai-styles">
   (the invisible stylesheet). Now a real file.
   MUST load AFTER styles.css in index.html: the injected block used
   to win same-specificity ties by coming later in the document, and
   this preserves that cascade exactly.
   NOTE: forks.js still injects its own fork-UI styles at runtime
   (#forks-styles) — same extraction is a good future job.
===================================================== */

/* ------ PANEL SHELL ------ */

.ai-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #2a1a0e;
    font-family: Georgia,serif;
    color: #f2dfc2;
    box-sizing: border-box;
}

/* ------ TOP BAR ------ */

.ai-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px 6px;
    border-bottom: 1px solid #3d2010;
    background: #1e1208;
    flex-shrink: 0;
}

.ai-bar-title {
    flex: 1;
    font-size: 12px;
    color: #8a6a4a;
    font-style: italic;
}

.ai-btn {
    background: transparent;
    border: 1px solid #5a3020;
    color: #8a6a4a;
    padding: 3px 8px;
    cursor: pointer;
    font-family: Georgia,serif;
    font-size: 11px;
    border-radius: 3px;
    transition: all 0.15s;
    white-space: nowrap;
}

.ai-btn:hover {
    border-color: #c8825a;
    color: #f0c090;
    background: #3a1a0a;
}

/* ------ MESSAGES ------ */

.ai-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: #4a2810 transparent;
}

.ai-msgs::-webkit-scrollbar {
    width: 4px;
}

.ai-msgs::-webkit-scrollbar-thumb {
    background: #4a2810;
    border-radius: 2px;
}

.ai-msg {
    max-width: 92%;
    line-height: 1.6;
    font-size: 16px;
}

.ai-msg img {
    max-width: 300px;
    max-height: 200px;
    border-radius: 6px;
    display: block;
    margin: 8px 0;
    border: 1px solid #5a3020;
}

.ai-user {
    align-self: flex-start;
    background: #3d2010;
    border: 1px solid #5a3020;
    border-radius: 10px 10px 10px 2px;
    padding: 10px 14px;
    color: #f0d8b0;
}

.ai-assistant {
    align-self: flex-start;
    background: #1e1208;
    border: 1px solid #3d2010;
    border-radius: 2px 10px 10px 10px;
    padding: 12px 16px;
    color: #f2dfc2;
    white-space: pre-wrap;
    width: 100%;
    box-sizing: border-box;
}

.ai-assistant strong {
    color: #e8b870;
}

.ai-thinking {
    align-self: flex-start;
    color: #6a4a2a;
    font-style: italic;
    font-size: 13px;
    padding: 4px 0;
    animation: ai-pulse 1.2s ease-in-out infinite;
}

@keyframes ai-pulse {
    0%,100% {
        opacity: .4;
    }
    50% {
        opacity: 1;
    }
}

/* ------ INPUT AREA ------ */

.ai-input-area {
    display: flex;
    flex-direction: column;
    border-top: 1px solid #3d2010;
    background: #1e1208;
    flex-shrink: 0;
    padding: 8px 14px 12px;
    gap: 6px;
}

.ai-preview-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-preview-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border: 1px solid #5a3020;
    border-radius: 4px;
    overflow: hidden;
    background: #2a1a0e;
}

.ai-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ai-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-input {
    flex: 1;
    background: #2a1a0e;
    border: 1px solid #5a3020;
    color: #f2dfc2;
    padding: 10px 14px;
    font-family: Georgia,serif;
    font-size: 16px;
    border-radius: 4px;
    outline: none;
    min-height: 80px;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.5;
    transition: border-color 0.15s;
    word-break: break-word;
}

.ai-input:focus {
    border-color: #a05030;
}

.ai-input:empty:before {
    content: attr(data-placeholder);
    color: #5a3a20;
    pointer-events: none;
}

.ai-send {
    background: #7a3a18;
    border: 1px solid #a05030;
    color: #f2dfc2;
    padding: 10px 18px;
    cursor: pointer;
    font-family: Georgia,serif;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
    height: 42px;
}

.ai-send:hover:not(:disabled) {
    background: #9a4a20;
    border-color: #c06030;
}

.ai-send:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* ------ ERRORS & INFO ------ */

.ai-error {
    align-self: flex-start;
    color: #c05030;
    font-size: 12px;
    font-style: italic;
    padding: 4px 0;
}

/* ------ FILE CHIPS ------ */

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid #5a3020;
    border-radius: 20px;
    font-size: 12px;
    font-family: Monaco,monospace;
    color: #c8a070;
    background: #1e1208;
    cursor: pointer;
    margin: 6px 0;
}

.file-chip:hover {
    border-color: #c8825a;
    color: #f0c090;
    background: #2a1708;
}

/* ------ CODE / ARTIFACT PANEL ------ */

#clerk-code-panel {
    display: none;
    flex-direction: column;
    border-left: 1px solid #3d2010;
    background: #111;
    min-width: 0;
    width: 45%;
}

#clerk-code-panel.open {
    display: flex;
}

#clerk-code-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #3d2010;
    background: #0d0d0d;
    flex-shrink: 0;
}

#clerk-code-panel-name {
    flex: 1;
    font-size: 12px;
    font-family: Monaco,monospace;
    color: #8a6a4a;
}

#clerk-code-panel-copy {
    background: transparent;
    border: 1px solid #5a3020;
    color: #8a6a4a;
    padding: 3px 8px;
    cursor: pointer;
    font-family: Georgia,serif;
    font-size: 11px;
    border-radius: 3px;
}

#clerk-code-panel-copy:hover {
    border-color: #c8825a;
    color: #f0c090;
}

#clerk-code-panel-close {
    background: transparent;
    border: none;
    color: #8a6a4a;
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    line-height: 1;
}

#clerk-code-panel-close:hover {
    color: #f0c090;
}

#clerk-code-panel-body {
    flex: 1;
    overflow: auto;
    padding: 0;
}

/* ------ SURGICAL DIFF VIEW ------ */

.clerk-surgical {
    margin: 0;
    border-bottom: 1px solid #2a1708;
}

.clerk-surgical-label {
    padding: 5px 14px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-family: Georgia,serif;
}

.clerk-surgical-label.remove {
    background: #2a0a0a;
    color: #e07070;
    border-bottom: 1px solid #4a1010;
}

.clerk-surgical-label.add {
    background: #0a1f0a;
    color: #70c070;
    border-bottom: 1px solid #104a10;
}

.clerk-surgical-label.arrow {
    background: #111;
    color: #5a3a20;
    text-align: center;
    padding: 3px;
    font-size: 13px;
    border-bottom: 1px solid #2a1708;
}

.clerk-surgical pre {
    margin: 0;
    padding: 10px 14px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.clerk-surgical pre.remove {
    background: #1a0505;
}

.clerk-surgical pre.add {
    background: #051a05;
}

.clerk-wholefile pre {
    margin: 0;
    padding: 14px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ------ CODE BLOCKS (chat messages) ------ */

.code-block {
    position: relative;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    margin: 12px 0;
    font-family: 'Monaco','Menlo','Ubuntu Mono',monospace;
    width: 100%;
    overflow: hidden;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #252525;
    border-bottom: 1px solid #333;
}

.code-block-lang {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-block-copy {
    background: transparent;
    border: 1px solid #555;
    color: #aaa;
    padding: 3px 7px;
    cursor: pointer;
    font-size: 11px;
    border-radius: 3px;
    transition: opacity 0.15s,background 0.15s;
    opacity: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
}

.code-block:hover .code-block-copy {
    opacity: 1;
}

.code-block-copy:hover {
    background: #333;
    border-color: #777;
    color: #fff;
}

.copy-icon-wrap {
    position: relative;
    display: inline-block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.copy-icon-wrap .sq1 {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 9px;
    height: 9px;
    border: 1.5px solid currentColor;
    border-radius: 1px;
    background: #252525;
}

.copy-icon-wrap .sq2 {
    position: absolute;
    top: 0;
    right: 0;
    width: 9px;
    height: 9px;
    border: 1.5px solid currentColor;
    border-radius: 1px;
    background: #252525;
}

.code-block-body {
    padding: 14px;
    overflow-x: auto;
    background: #1a1a1a;
    color: #f8f8f2;
    font-size: 14px;
    line-height: 1.5;
}

.code-block-body pre {
    margin: 0;
    white-space: pre;
}

.ai-info {
    align-self: center;
    color: #5a3a20;
    font-size: 12px;
    font-style: italic;
    padding: 2px 0;
}