/* Worker Script Tester — Dark Electric Indigo Theme */
:root {
    --primary: #6366F1;
    --primary-hover: #7C7FF7;
    --primary-glow: rgba(99, 102, 241, 0.25);
    --secondary: #818CF8;
    --accent: #F59E0B;
    --accent-hover: #FBBF24;
    --bg: #0F1219;
    --bg-panel: #161B26;
    --bg-elevated: #1C2333;
    --bg-input: #111827;
    --border: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.35);
    --text: #E5E7EB;
    --text-muted: #9CA3AF;
    --text-dim: #6B7280;
    --success: #34D399;
    --error: #F87171;
    --warning: #FBBF24;
    --info: #60A5FA;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --transition: 200ms ease;
    --glass-bg: rgba(22, 27, 38, 0.75);
    --glass-border: rgba(99, 102, 241, 0.12);
    --glass-blur: blur(16px);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px
}

::-webkit-scrollbar-track {
    background: transparent
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover)
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.25rem;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    z-index: 10;
    flex-shrink: 0
}

.header-brand {
    display: flex;
    align-items: center;
    gap: .75rem
}

.header-logo {
    display: flex;
    align-items: center;
    animation: pulseGlow 3s ease-in-out infinite
}

@keyframes pulseGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 4px var(--primary-glow))
    }

    50% {
        filter: drop-shadow(0 0 12px var(--primary-glow))
    }
}

.header-title {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.header-badge {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--accent);
    background: rgba(245, 158, 11, .12);
    border: 1px solid rgba(245, 158, 11, .25);
    padding: .2rem .5rem;
    border-radius: var(--radius-xs)
}

.header-actions {
    display: flex;
    align-items: center;
    gap: .5rem
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-family: var(--font);
    font-size: .8rem;
    font-weight: 600;
    padding: .5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    user-select: none
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #4F46E5);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow)
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), #6366F1);
    box-shadow: 0 0 28px var(--primary-glow);
    transform: translateY(-1px)
}

.btn-primary:active {
    transform: translateY(0)
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border)
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--bg-elevated);
    border-color: var(--border-hover)
}

.btn-sm {
    font-size: .72rem;
    padding: .3rem .6rem;
    border-radius: var(--radius-xs)
}

.btn-add-row {
    width: 100%;
    justify-content: center;
    margin-top: .4rem;
    border-style: dashed;
    color: var(--text-dim)
}

.btn-add-row:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(99, 102, 241, .06)
}

/* Main Layout */
.main-layout {
    display: grid;
    grid-template-columns: 1.2fr .9fr 1fr;
    gap: 1px;
    flex: 1;
    overflow: hidden;
    background: var(--border)
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    overflow: hidden
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0
}

.panel-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em
}

.panel-title svg {
    opacity: .6
}

.panel-actions {
    display: flex;
    gap: .4rem
}

/* Editor */
.editor-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    min-height: 200px
}

.line-numbers {
    width: 3rem;
    padding: .75rem .5rem;
    text-align: right;
    font-family: var(--font-mono);
    font-size: .78rem;
    line-height: 1.6;
    color: var(--text-dim);
    background: rgba(0, 0, 0, .15);
    border-right: 1px solid var(--border);
    overflow: hidden;
    user-select: none;
    flex-shrink: 0
}

.editor {
    flex: 1;
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: .82rem;
    line-height: 1.6;
    padding: .75rem 1rem;
    border: none;
    outline: none;
    resize: none;
    tab-size: 2;
    -moz-tab-size: 2;
    overflow: auto;
    white-space: pre
}

.editor::placeholder {
    color: var(--text-dim);
    opacity: .5
}

.editor:focus {
    box-shadow: inset 0 0 0 1px var(--primary)
}

/* Env Variables */
.env-section {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    max-height: 180px;
    overflow-y: auto
}

.env-vars-list {
    padding: .5rem 1rem
}

.env-row,
.kv-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: .4rem;
    margin-bottom: .35rem;
    animation: fadeIn 200ms ease
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.env-row input,
.kv-row input {
    font-family: var(--font-mono);
    font-size: .78rem;
    padding: .4rem .6rem;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    outline: none;
    transition: border-color var(--transition)
}

.env-row input:focus,
.kv-row input:focus {
    border-color: var(--primary)
}

.env-row input::placeholder,
.kv-row input::placeholder {
    color: var(--text-dim)
}

.btn-remove-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition);
    align-self: center
}

.btn-remove-row:hover {
    color: var(--error);
    background: rgba(248, 113, 113, .1);
    border-color: rgba(248, 113, 113, .3)
}

/* Request Panel */
.panel-request {
    overflow-y: auto
}

.request-url-bar {
    display: flex;
    gap: 0;
    margin: .75rem 1rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color var(--transition)
}

.request-url-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow)
}

.select-method {
    font-family: var(--font);
    font-size: .8rem;
    font-weight: 600;
    padding: .55rem .75rem;
    background: var(--bg-elevated);
    color: var(--accent);
    border: none;
    border-right: 1px solid var(--border);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    min-width: 80px
}

.select-method option {
    background: var(--bg-panel);
    color: var(--text)
}

.input-url {
    flex: 1;
    font-family: var(--font-mono);
    font-size: .8rem;
    padding: .55rem .75rem;
    background: var(--bg-input);
    color: var(--text);
    border: none;
    outline: none
}

.input-url::placeholder {
    color: var(--text-dim)
}

.request-section {
    padding: .75rem 1rem;
    border-top: 1px solid var(--border)
}

.section-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .5rem
}

.kv-list {
    margin-bottom: .25rem
}

/* Body type */
.body-type-bar {
    display: flex;
    gap: .35rem;
    margin-bottom: .5rem
}

.body-type-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: .72rem
}

.body-type-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary)
}

.body-type-btn:hover:not(.active) {
    background: var(--bg-elevated)
}

.input-body {
    width: 100%;
    min-height: 100px;
    font-family: var(--font-mono);
    font-size: .8rem;
    line-height: 1.5;
    padding: .6rem .75rem;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    resize: vertical;
    transition: border-color var(--transition)
}

.input-body:focus {
    border-color: var(--primary)
}

/* Response Panel */
.panel-response {
    display: flex;
    flex-direction: column
}

.response-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.response-meta {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .72rem;
    font-weight: 600
}

.status-badge {
    padding: .15rem .5rem;
    border-radius: var(--radius-xs);
    font-family: var(--font-mono)
}

.status-badge.success {
    color: var(--success);
    background: rgba(52, 211, 153, .12)
}

.status-badge.error {
    color: var(--error);
    background: rgba(248, 113, 113, .12)
}

.status-badge.info {
    color: var(--info);
    background: rgba(96, 165, 250, .12)
}

.response-time {
    color: var(--text-dim);
    font-family: var(--font-mono)
}

/* Tabs */
.response-tabs {
    display: flex;
    gap: 0;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0
}

.tab {
    font-family: var(--font);
    font-size: .76rem;
    font-weight: 500;
    padding: .5rem .9rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition)
}

.tab:hover {
    color: var(--text)
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary)
}

.tab-content {
    display: none;
    flex: 1;
    overflow: auto
}

.tab-content.active {
    display: block
}

.response-output {
    font-family: var(--font-mono);
    font-size: .8rem;
    line-height: 1.6;
    padding: .75rem 1rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
    min-height: 80px
}

.placeholder-text {
    color: var(--text-dim);
    font-style: italic
}

/* Console */
.console-section {
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    max-height: 200px;
    display: flex;
    flex-direction: column
}

.console-output {
    font-family: var(--font-mono);
    font-size: .78rem;
    line-height: 1.6;
    padding: .5rem 1rem;
    overflow-y: auto;
    flex: 1;
    min-height: 60px
}

.console-log {
    color: var(--text)
}

.console-warn {
    color: var(--warning)
}

.console-error {
    color: var(--error)
}

.console-info {
    color: var(--info)
}

.console-entry {
    padding: .15rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, .03);
    animation: fadeIn 150ms ease
}

.console-entry-prefix {
    color: var(--text-dim);
    margin-right: .5rem;
    font-size: .7rem
}

/* Error Section */
.error-section {
    border-top: 2px solid var(--error);
    flex-shrink: 0
}

.error-title {
    color: var(--error) !important
}

.error-output {
    font-family: var(--font-mono);
    font-size: .78rem;
    line-height: 1.6;
    padding: .5rem 1rem;
    color: var(--error);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto
}

/* Status Bar */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .35rem 1.25rem;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    font-size: .7rem;
    color: var(--text-dim);
    flex-shrink: 0
}

.status-text {
    display: flex;
    align-items: center;
    gap: .4rem
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: blink 1.5s ease-in-out infinite
}

@keyframes blink {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .3
    }
}

.status-time {
    font-family: var(--font-mono);
    font-size: .68rem
}

.btn-primary.running {
    pointer-events: none;
    opacity: .85
}

.btn-primary.running svg {
    animation: spin .8s linear infinite
}

@keyframes spin {
    from {
        transform: rotate(0)
    }

    to {
        transform: rotate(360deg)
    }
}

/* Responsive */
@media(max-width:1100px) {
    .main-layout {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr
    }

    .panel-editor {
        grid-column: 1/-1
    }
}

@media(max-width:700px) {
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        overflow-y: auto
    }

    .panel {
        max-height: 50vh;
        overflow-y: auto
    }

    .header {
        flex-wrap: wrap;
        gap: .5rem
    }

    .header-badge {
        display: none
    }

    body {
        overflow: auto
    }
}