/* ============================================================
   Coral — Design Tokens / CSS Custom Properties
   ============================================================
   Theme is controlled via data-theme attribute on <html>.
   Values: "dark" (default), "light".
   The "system" option is handled in JS by mapping to dark/light.
   ============================================================ */

/* ── Dark Theme (default) ──────────────────────────────────── */

:root,
[data-theme="dark"] {
    /* Surface / Background */
    --bg-primary:   #0a0e14;
    --bg-secondary: #12171e;
    --bg-tertiary:  #1c2128;
    --bg-hover:     #2a313a;
    --bg-elevated:  #252b33;

    /* Borders */
    --border:       #30363d;
    --border-light: #484f58;

    /* Text */
    --text-primary:   #e6edf3;
    --text-secondary: #8b949e;
    --text-muted:     #484f58;

    /* Accent / Brand */
    --accent:     #58a6ff;
    --accent-dim: #1f6feb;

    /* Semantic Status */
    --success: #3fb950;
    --warning: #d29922;
    --error:   #f85149;

    /* Agent Badges */
    --badge-claude: #7c3aed;
    --badge-gemini: #2563eb;

    /* Shadows */
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);

    /* Typography */
    --font-sans:  'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:  'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Syntax Highlighting */
    --sh-keyword:   #ff7b72;
    --sh-string:    #a5d6ff;
    --sh-comment:   #8b949e;
    --sh-number:    #79c0ff;
    --sh-builtin:   #ffa657;
    --sh-decorator: #d2a8ff;

    /* Diff */
    --diff-add-bg:    rgba(63, 185, 80, 0.15);
    --diff-add-color: #3fb950;
    --diff-del-bg:    rgba(248, 81, 73, 0.15);
    --diff-del-color: #f85149;

    /* Tool / Event Colors */
    --color-tool-read:       var(--accent);
    --color-tool-write:      var(--success);
    --color-tool-edit:       var(--warning);
    --color-tool-bash:       #d2a8ff;
    --color-tool-grep:       #79c0ff;
    --color-tool-web:        #ffa657;
    --color-tool-task:       var(--accent);
    --color-tool-agent:      #d2a8ff;
    --color-tool-status:     var(--accent);
    --color-tool-goal:       var(--success);
    --color-tool-confidence: #e3b341;
    --color-tool-stop:       var(--error);
    --color-tool-pulse:      #bc8cff;
    --color-tool-default:    var(--text-muted);

    /* Modal backdrop */
    --modal-backdrop: rgba(0, 0, 0, 0.6);

    /* Chat */
    --chat-human-bg:    var(--accent-dim);
    --chat-human-color: var(--text-primary);

    /* Chat / markdown specifics */
    --code-inline-bg:  rgba(255, 255, 255, 0.07);
    --code-block-bg:   rgba(0, 0, 0, 0.35);
    --table-header-bg: rgba(0, 0, 0, 0.2);

    /* Capture blocks */
    --capture-text-bg:   rgba(110, 118, 129, 0.06);
    --capture-tool-bg:   rgba(88, 166, 255, 0.05);
    --capture-user-bg:   rgba(201, 160, 255, 0.08);
    --capture-pulse-bg:  rgba(63, 185, 80, 0.08);
    --capture-code-bg:   rgba(110, 118, 129, 0.1);
    --capture-user-color: #c9a0ff;

    /* Top bar */
    --topbar-bg: rgba(18, 23, 30, 0.85);
    --topbar-border: rgba(48, 54, 61, 0.6);

    /* Terminal (xterm) */
    --xterm-background:          #0d1117;
    --xterm-foreground:          #e6edf3;
    --xterm-cursor:              #e6edf3;
    --xterm-selection-background:#264f78;
    --xterm-black:               #484f58;
    --xterm-red:                 #f85149;
    --xterm-green:               #3fb950;
    --xterm-yellow:              #d29922;
    --xterm-blue:                #58a6ff;
    --xterm-magenta:             #bc8cff;
    --xterm-cyan:                #39d2c0;
    --xterm-white:               #e6edf3;
    --xterm-bright-black:        #6e7681;
    --xterm-bright-red:          #ffa198;
    --xterm-bright-green:        #56d364;
    --xterm-bright-yellow:       #e3b341;
    --xterm-bright-blue:         #79c0ff;
    --xterm-bright-magenta:      #d2a8ff;
    --xterm-bright-cyan:         #56d4dd;
    --xterm-bright-white:        #f0f6fc;

    /* Diff2html overrides */
    --d2h-code-bg:        #0d1117;
    --d2h-gutter-bg:      #161b22;
    --d2h-ins-bg:         #1a3326;
    --d2h-ins-gutter-bg:  #1c3828;
    --d2h-ins-highlight:  #264d35;
    --d2h-del-bg:         #331a1f;
    --d2h-del-gutter-bg:  #381c22;
    --d2h-del-highlight:  #4d262d;
    --d2h-empty-bg:       #151b22;
    --d2h-hunk-bg:        #111a24;
}

/* ── Light Theme ───────────────────────────────────────────── */

[data-theme="light"] {
    /* Surface / Background — warm off-white, not pure white */
    --bg-primary:   #f4f5f7;
    --bg-secondary: #ecedf0;
    --bg-tertiary:  #e2e4e8;
    --bg-hover:     #d8dbe0;
    --bg-elevated:  #e8eaed;

    /* Borders */
    --border:       #c9cdd3;
    --border-light: #b0b6be;

    /* Text */
    --text-primary:   #1f2328;
    --text-secondary: #59636e;
    --text-muted:     #8b949e;

    /* Accent / Brand */
    --accent:     #0969da;
    --accent-dim: #0550ae;

    /* Semantic Status */
    --success: #1a7f37;
    --warning: #9a6700;
    --error:   #cf222e;

    /* Agent Badges */
    --badge-claude: #7c3aed;
    --badge-gemini: #2563eb;

    /* Shadows */
    --shadow-md: 0 4px 16px rgba(31, 35, 40, 0.12);
    --shadow-lg: 0 8px 32px rgba(31, 35, 40, 0.16);

    /* Syntax Highlighting */
    --sh-keyword:   #cf222e;
    --sh-string:    #0a3069;
    --sh-comment:   #6e7781;
    --sh-number:    #0550ae;
    --sh-builtin:   #953800;
    --sh-decorator: #8250df;

    /* Diff */
    --diff-add-bg:    rgba(26, 127, 55, 0.12);
    --diff-add-color: #1a7f37;
    --diff-del-bg:    rgba(207, 34, 46, 0.12);
    --diff-del-color: #cf222e;

    /* Tool / Event Colors */
    --color-tool-read:       #0969da;
    --color-tool-write:      #1a7f37;
    --color-tool-edit:       #9a6700;
    --color-tool-bash:       #8250df;
    --color-tool-grep:       #0550ae;
    --color-tool-web:        #953800;
    --color-tool-task:       #0969da;
    --color-tool-agent:      #8250df;
    --color-tool-status:     #0969da;
    --color-tool-goal:       #1a7f37;
    --color-tool-confidence: #9a6700;
    --color-tool-stop:       #cf222e;
    --color-tool-pulse:      #8250df;
    --color-tool-default:    #8b949e;

    /* Modal backdrop */
    --modal-backdrop: rgba(31, 35, 40, 0.4);

    /* Chat */
    --chat-human-bg:    #d4e4f7;
    --chat-human-color: #1f2328;

    /* Chat / markdown specifics */
    --code-inline-bg:  rgba(31, 35, 40, 0.07);
    --code-block-bg:   #e2e4e8;
    --table-header-bg: #e2e4e8;

    /* Capture blocks */
    --capture-text-bg:   rgba(89, 99, 110, 0.06);
    --capture-tool-bg:   rgba(9, 105, 218, 0.06);
    --capture-user-bg:   rgba(130, 80, 223, 0.08);
    --capture-pulse-bg:  rgba(26, 127, 55, 0.06);
    --capture-code-bg:   rgba(89, 99, 110, 0.08);
    --capture-user-color: #8250df;

    /* Top bar */
    --topbar-bg: rgba(236, 237, 240, 0.92);
    --topbar-border: rgba(201, 205, 211, 0.8);

    /* Terminal (xterm) */
    --xterm-background:          #c8ccd2;
    --xterm-foreground:          #1f2328;
    --xterm-cursor:              #1f2328;
    --xterm-selection-background:#a8c8f0;
    --xterm-black:               #1f2328;
    --xterm-red:                 #cf222e;
    --xterm-green:               #1a7f37;
    --xterm-yellow:              #9a6700;
    --xterm-blue:                #0969da;
    --xterm-magenta:             #8250df;
    --xterm-cyan:                #1b7c83;
    --xterm-white:               #59636e;
    --xterm-bright-black:        #59636e;
    --xterm-bright-red:          #a40e26;
    --xterm-bright-green:        #116329;
    --xterm-bright-yellow:       #7c5600;
    --xterm-bright-blue:         #0550ae;
    --xterm-bright-magenta:      #6639ba;
    --xterm-bright-cyan:         #1b7c83;
    --xterm-bright-white:        #1f2328;

    /* Diff2html overrides */
    --d2h-code-bg:        #f4f5f7;
    --d2h-gutter-bg:      #ecedf0;
    --d2h-ins-bg:         #d4f4db;
    --d2h-ins-gutter-bg:  #c5edcf;
    --d2h-ins-highlight:  #a6e4b4;
    --d2h-del-bg:         #fce4e2;
    --d2h-del-gutter-bg:  #f5cbc8;
    --d2h-del-highlight:  #f0b3ae;
    --d2h-empty-bg:       #ecedf0;
    --d2h-hunk-bg:        #d6edf8;
}
