/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:         #0e1117;
    --surface:    #161b22;
    --surface-2:  #1c2129;
    --border:     #2d333b;
    --border-hl:  #444c56;
    --text:       #e6edf3;
    --text-dim:   #8b949e;
    --text-faint: #6e7681;
    --accent:     #58a6ff;
    --accent-dim: #1a3a5c;
    --green:      #3fb950;
    --green-dim:  #1a3d2a;
    --red:        #f85149;
    --red-dim:    #3d1a1a;
    --orange:     #d29922;
    --radius:     6px;
    --mono:       'JetBrains Mono', monospace;
    --sans:       'Plus Jakarta Sans', -apple-system, sans-serif;
}

html { font-size: 15px; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ── App Shell ── */
.app-shell { max-width: 760px; margin: 0 auto; padding: 0 1rem; }

/* ── Top Bar ── */
.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem;
}
.logo { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.logo-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; background: var(--accent); color: var(--bg); border-radius: 4px; font-size: 0.75rem;
}
nav { display: flex; gap: 0.25rem; }
.nav-link {
    padding: 0.35rem 0.75rem; border-radius: var(--radius); color: var(--text-dim);
    text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { background: var(--surface-2); color: var(--text); }

/* ── Content ── */
.content { padding-bottom: 3rem; }

/* ── Flash Messages ── */
.flash { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1.5rem; font-size: 0.9rem; font-family: var(--mono); }
.flash code { background: rgba(255,255,255,0.08); padding: 0.1em 0.4em; border-radius: 3px; }
.flash-success { background: var(--green-dim); border: 1px solid var(--green); color: var(--green); }
.flash-error   { background: var(--red-dim); border: 1px solid var(--red); color: var(--red); }

/* ── Form Sections ── */
.form-section {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem; margin-bottom: 1rem;
}
.section-title {
    font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 1rem;
}
.section-title .badge {
    background: var(--accent-dim); color: var(--accent); padding: 0.15em 0.5em;
    border-radius: 10px; font-size: 0.75rem; margin-left: 0.35rem;
}
.section-header-row {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;
}
.section-header-row .section-title { margin-bottom: 0; }

/* ── Drop Zone ── */
.drop-zone {
    border: 2px dashed var(--border); border-radius: var(--radius); padding: 2rem;
    text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s; position: relative;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); background: var(--accent-dim); }
.drop-zone input[type="file"] { position: absolute; opacity: 0; width: 0; height: 0; }
.drop-zone-prompt { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.drop-icon { font-size: 1.5rem; opacity: 0.6; }
.drop-zone-prompt p { color: var(--text-dim); font-size: 0.9rem; }
.drop-hint { font-size: 0.8rem !important; color: var(--text-faint) !important; }
.browse-link { color: var(--accent); text-decoration: underline; }
.drop-zone-preview { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
.drop-zone-preview video { max-width: 100%; max-height: 300px; border-radius: 4px; background: #000; }

/* ── Fields ── */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field label {
    display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text);
}
.label-hint { font-weight: 400; color: var(--text-faint); font-size: 0.75rem; }

.field input[type="text"],
.field input[type="number"],
.field input[type="datetime-local"],
.field textarea,
.field select {
    width: 100%; padding: 0.55rem 0.7rem; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-family: var(--sans); font-size: 0.85rem;
    transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim);
}
.field textarea { resize: vertical; min-height: 65px; }
.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.7rem center; padding-right: 2rem;
}
.char-count { text-align: right; font-size: 0.7rem; color: var(--text-faint); margin-top: 0.2rem; font-family: var(--mono); }

/* Color input */
.input-color {
    width: 100% !important; height: 36px; padding: 2px !important; cursor: pointer;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
}

/* Field rows */
.field-row   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.65rem; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.65rem; }
.field-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 0.65rem; }
.field-hint { font-size: 0.8rem; color: var(--text-faint); margin-top: 0.35rem; }
.field-hint code { background: var(--bg); padding: 0.1em 0.4em; border-radius: 3px; font-family: var(--mono); font-size: 0.75rem; }

/* ── Toggle / checkbox styling ── */
.toggle-row { display: flex; gap: 0.35rem; flex-wrap: wrap; padding-top: 0.2rem; }
.toggle-label {
    display: inline-flex; align-items: center; gap: 0.25rem; cursor: pointer;
    padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.8rem;
    background: var(--bg); border: 1px solid var(--border); color: var(--text-dim);
    transition: all 0.15s; user-select: none;
}
.toggle-label:has(input:checked) {
    background: var(--accent-dim); border-color: var(--accent); color: var(--accent);
}
.toggle-label input { display: none; }

.standalone-toggle { margin-top: 0.5rem; }

/* ── Overlay Blocks ── */
.overlay-block {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem; margin-bottom: 0.75rem;
}
.overlay-block:last-child { margin-bottom: 0; }

.overlay-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem;
}
.overlay-label { font-size: 0.8rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }

.btn-remove-overlay {
    background: none; border: 1px solid var(--border); color: var(--text-faint);
    width: 26px; height: 26px; border-radius: 4px; cursor: pointer; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.btn-remove-overlay:hover { color: var(--red); border-color: var(--red); }

.btn-add {
    background: var(--accent-dim); border: 1px solid var(--accent); color: var(--accent);
    padding: 0.3rem 0.75rem; border-radius: var(--radius); cursor: pointer;
    font-size: 0.8rem; font-weight: 600; font-family: var(--sans); transition: opacity 0.15s;
}
.btn-add:hover { opacity: 0.85; }

/* ── Advanced toggle ── */
.advanced-toggle { margin-top: 0.75rem; }
.advanced-toggle summary {
    font-size: 0.75rem; color: var(--text-faint); cursor: pointer; user-select: none;
    padding: 0.3rem 0; list-style: none;
}
.advanced-toggle summary::before { content: "▸ "; }
.advanced-toggle[open] summary::before { content: "▾ "; }

/* ── Platform Selection ── */
.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.5rem; }
.platform-option { cursor: pointer; }
.platform-option input { display: none; }
.platform-card {
    display: flex; align-items: center; justify-content: center;
    padding: 0.65rem 1rem; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); transition: all 0.15s; text-align: center;
}
.platform-card:hover { border-color: var(--border-hl); }
.platform-option input:checked + .platform-card { border-color: var(--accent); background: var(--accent-dim); }
.platform-name { font-size: 0.9rem; font-weight: 600; }

/* ── Buttons ── */
.btn-submit {
    display: block; width: 100%; padding: 0.85rem; background: var(--accent); color: var(--bg);
    border: none; border-radius: var(--radius); font-family: var(--sans); font-size: 1rem;
    font-weight: 700; cursor: pointer; transition: opacity 0.15s;
}
.btn-submit:hover { opacity: 0.9; }
.btn-submit:disabled { opacity: 0.5; cursor: wait; }
.btn-clear {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
    padding: 0.35rem 0.75rem; border-radius: var(--radius); cursor: pointer; font-size: 0.8rem;
}
.btn-clear:hover { color: var(--red); border-color: var(--red); }
.form-actions { margin-top: 1rem; }

/* ── Queue Cards ── */
.job-list { display: flex; flex-direction: column; gap: 0.5rem; }
.job-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.job-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.job-id { font-family: var(--mono); font-size: 0.8rem; color: var(--text-dim); background: var(--bg); padding: 0.15em 0.5em; border-radius: 3px; }
.job-status { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.2em 0.6em; border-radius: 10px; }
.status-pending .job-status    { background: var(--accent-dim); color: var(--accent); }
.status-processing .job-status { background: rgba(210,153,34,0.15); color: var(--orange); }
.status-done .job-status       { background: var(--green-dim); color: var(--green); }
.status-partial .job-status    { background: rgba(210,153,34,0.15); color: var(--orange); }
.status-error .job-status      { background: var(--red-dim); color: var(--red); }
.job-hook { font-size: 1rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--text); }
.job-meta { display: flex; gap: 0.75rem; font-size: 0.8rem; color: var(--text-dim); flex-wrap: wrap; }
.job-schedule { font-size: 0.8rem; color: var(--orange); margin-top: 0.35rem; }
.job-time { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.5rem; }
.job-results { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.5rem; }
.result-chip { font-size: 0.75rem; padding: 0.15em 0.5em; border-radius: 3px; font-family: var(--mono); }
.result-success { background: var(--green-dim); color: var(--green); }
.result-error   { background: var(--red-dim); color: var(--red); }
.empty-state { padding: 2rem; text-align: center; color: var(--text-faint); font-size: 0.9rem; }

/* ── Responsive ── */
@media (max-width: 640px) {
    .field-row, .field-row-3, .field-row-4 { grid-template-columns: 1fr 1fr; }
    .platform-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
    .field-row, .field-row-3, .field-row-4 { grid-template-columns: 1fr; }
}