/* ===========================================================
   GPT Register Manager — Style Sheet
   =========================================================== */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --bg:             #f4f5f7;
    --surface:        #ffffff;
    --surface-hover:  #f9fafb;
    --border:         #e5e7eb;
    --border-light:   #f0f2f5;

    --text:           #111827;
    --text-muted:     #6b7280;
    --text-light:     #9ca3af;

    --primary:        #1d4ed8;
    --primary-hover:  #1e40af;
    --primary-light:  #eff6ff;

    --success:        #16a34a;
    --success-light:  #f0fdf4;
    --success-border: #bbf7d0;

    --danger:         #dc2626;
    --danger-light:   #fef2f2;
    --danger-border:  #fecaca;

    --warning:        #d97706;
    --warning-light:  #fffbeb;
    --warning-border: #fde68a;

    --info:           #0891b2;
    --info-light:     #ecfeff;

    --purple:         #7c3aed;
    --purple-light:   #f5f3ff;

    --radius-sm:   4px;
    --radius:      8px;
    --radius-lg:   12px;
    --radius-xl:   16px;

    --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow:      0 1px 4px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.10);
    --shadow-lg:   0 8px 24px rgba(0, 0, 0, 0.12);

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', 'SF Mono', monospace;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
}

button {
    cursor: pointer;
}

/* ── Layout ────────────────────────────────────────────────── */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Navigation ────────────────────────────────────────────── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 56px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 32px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-brand .brand-icon {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
}

.nav-menu {
    display: flex;
    gap: 2px;
    flex: 1;
}

.nav-item {
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 28px;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.page-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text);
}

.card-body {
    padding: 20px;
}

/* ── Stat Cards ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Badges / Status Pills ─────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-purple  { background: var(--purple-light);  color: var(--purple); }
.badge-neutral { background: var(--border-light);  color: var(--text-muted); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12.5px;
}

.btn-xs {
    padding: 3px 9px;
    font-size: 12px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
    background: #15803d;
}

.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger-border);
}

.btn-danger:hover:not(:disabled) {
    background: #fee2e2;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg);
    color: var(--text);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 15px;
    transition: background 0.15s, color 0.15s;
}

.btn-icon:hover:not(:disabled) {
    background: var(--bg);
    color: var(--text);
}

/* ── Form Controls ─────────────────────────────────────────── */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
}

.form-input,
.form-select,
.form-textarea {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 13.5px;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

/* Toggle Switch */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: 99px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle input:checked + .toggle-track {
    background: var(--primary);
}

.toggle-track::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: left 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .toggle-track::after {
    left: 20px;
}

.toggle-label {
    font-size: 13px;
    color: var(--text);
}

/* ── Table ─────────────────────────────────────────────────── */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13.5px;
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: var(--surface-hover);
}

.col-check {
    width: 40px;
    padding-left: 16px;
    padding-right: 4px;
}

input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ── Toolbar ───────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    background: var(--bg);
}

.toolbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-input {
    width: 230px;
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    padding: 12px 16px;
}

.page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.page-btn:hover:not(:disabled):not(.active) {
    background: var(--bg);
}

.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-left: 8px;
}

/* ── Task Grid ─────────────────────────────────────────────── */
.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 14px;
}

.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: box-shadow 0.2s;
}

.task-card:hover {
    box-shadow: var(--shadow);
}

.task-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.task-idx {
    font-size: 11px;
    color: var(--text-light);
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1px 6px;
    font-weight: 500;
}

.task-email {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 3px;
}

.task-message {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-height: 16px;
}

.task-progress {
    margin-top: 12px;
}

.progress-bar-wrap {
    height: 6px;
    background: var(--border-light);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 99px;
    background: var(--primary);
    transition: width 0.4s ease;
}

.progress-bar.state-success { background: var(--success); }
.progress-bar.state-failed  { background: var(--danger); }
.progress-bar.state-retrying { background: var(--warning); }

.progress-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 5px;
}

.progress-pct {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
}

.step-dots {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-light);
    transition: background 0.25s;
}

.step-dot.done    { background: var(--success); }
.step-dot.active  { background: var(--primary); }
.step-dot.failed  { background: var(--danger); }

.task-error {
    margin-top: 8px;
    padding: 6px 10px;
    background: var(--danger-light);
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    color: var(--danger);
    word-break: break-word;
    line-height: 1.4;
}

/* ── Batch Banner ──────────────────────────────────────────── */
.batch-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.batch-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.batch-stats {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.batch-stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.batch-stat-item .num {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
}

.batch-progress-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 4px;
}

.batch-progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 99px;
    transition: width 0.5s ease;
}

/* ── Start Panel ───────────────────────────────────────────── */
.start-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.start-panel .form-grid-3 {
    gap: 14px;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 44px;
    margin-bottom: 12px;
    line-height: 1;
}

.empty-state .empty-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.empty-state .empty-desc {
    font-size: 13px;
}

/* ── Toast Notifications ───────────────────────────────────── */
.toast-stack {
    position: fixed;
    top: 68px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 320px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    box-shadow: var(--shadow-md);
    pointer-events: all;
    animation: toastIn 0.25s ease;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: none; }
}

@keyframes toastOut {
    from { opacity: 1; transform: none; max-height: 100px; margin-bottom: 0; }
    to   { opacity: 0; transform: translateX(16px); max-height: 0; margin-bottom: -8px; }
}

.toast.removing {
    animation: toastOut 0.25s ease forwards;
}

.toast-icon-wrap {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-success .toast-icon-wrap { background: var(--success-light); }
.toast-error   .toast-icon-wrap { background: var(--danger-light); }
.toast-info    .toast-icon-wrap { background: var(--primary-light); }
.toast-warning .toast-icon-wrap { background: var(--warning-light); }

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.toast-msg {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
    word-break: break-word;
}

/* ── Login Page ────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    width: 380px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    margin: 0 auto 20px;
    font-size: 24px;
    color: #fff;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    color: var(--text);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
}

.login-btn {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 16px;
}

/* ── Config Page ───────────────────────────────────────────── */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.config-section {
    margin-bottom: 0;
}

.config-section + .config-section {
    margin-top: 16px;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.toggle-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.toggle-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toggle-row-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.toggle-row-hint {
    font-size: 11.5px;
    color: var(--text-muted);
}

/* ── Code / Mono ───────────────────────────────────────────── */
.mono {
    font-family: var(--font-mono);
    font-size: 12px;
}

.token-cell {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-muted);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* ── Inline Utilities ──────────────────────────────────────── */
.flex        { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-4       { gap: 4px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.gap-20      { gap: 20px; }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.mt-20       { margin-top: 20px; }
.mb-16       { margin-bottom: 16px; }
.mb-20       { margin-bottom: 20px; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 12.5px; }
.text-xs     { font-size: 11.5px; }
.fw-600      { font-weight: 600; }

/* ── Spinner ───────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Divider ───────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border-light);
    margin: 16px 0;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .config-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    .navbar { padding: 0 16px; gap: 16px; }
    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .task-grid { grid-template-columns: 1fr; }
    .nav-menu { gap: 0; }
    .nav-item { padding: 6px 10px; font-size: 13px; }
}
