/* ============================================================
   GPT-AutoReg Pro — Dual Theme CSS
   Light (default) + Dark mode toggle
   ============================================================ */

/* --- Theme Variables --- */
:root,
[data-theme="light"] {
    --bg: #f1f5f9;
    --bg2: #ffffff;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;
    --sidebar-text: #64748b;
    --sidebar-active: #2563eb;
    --sidebar-active-bg: #eff6ff;
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --border: #e2e8f0;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-focus: #3b82f6;
    --accent: #3b82f6;
    --accent2: #2563eb;
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, .08);
    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, .08);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, .08);
    --table-stripe: #f8fafc;
    --table-header: #f1f5f9;
    --table-hover: #f1f5f9;
    --log-bg: #f8fafc;
    --progress-bg: #e2e8f0;
    --progress-fill: linear-gradient(90deg, #3b82f6, #60a5fa);
    --toast-bg: #ffffff;
    --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, .05), 0 2px 4px rgba(0, 0, 0, .03);
    --stat-gradient: linear-gradient(135deg, #3b82f6, #60a5fa);
    --radius: 10px;
}

[data-theme="dark"] {
    --bg: #0a0a14;
    --bg2: #12121e;
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --sidebar-bg: rgba(0, 0, 0, 0.35);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-text: #9a9ab0;
    --sidebar-active: #a29bfe;
    --sidebar-active-bg: rgba(108, 92, 231, 0.12);
    --text: #f0f0f5;
    --text-secondary: #c0c0d0;
    --text-muted: #9a9ab0;
    --text-dim: #5a5a70;
    --border: rgba(255, 255, 255, 0.08);
    --input-bg: rgba(255, 255, 255, 0.04);
    --input-border: rgba(255, 255, 255, 0.1);
    --input-focus: #6c5ce7;
    --accent: #6c5ce7;
    --accent2: #a29bfe;
    --success: #00b894;
    --success-bg: rgba(0, 184, 148, .1);
    --error: #ff6b6b;
    --error-bg: rgba(255, 107, 107, .1);
    --warning: #fdcb6e;
    --warning-bg: rgba(253, 203, 110, .1);
    --table-stripe: rgba(255, 255, 255, 0.015);
    --table-header: rgba(255, 255, 255, 0.03);
    --table-hover: rgba(255, 255, 255, 0.04);
    --log-bg: rgba(0, 0, 0, 0.25);
    --progress-bg: rgba(255, 255, 255, 0.06);
    --progress-fill: linear-gradient(90deg, #6c5ce7, #a29bfe);
    --toast-bg: #1a1a2e;
    --shadow: 0 2px 8px rgba(0, 0, 0, .4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, .5);
    --stat-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);
    --radius: 12px;
}

/* --- Reset & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: background .3s, color .3s;
}

/* --- Layout --- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 210px;
    min-width: 210px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: background .3s, border .3s;
}

.sidebar-logo {
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .75rem;
}

.sidebar-logo h1 {
    font-size: 1rem;
    font-weight: 800;
    background: var(--stat-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-logo span {
    font-size: .7rem;
    color: var(--text-dim);
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1.25rem;
    font-size: .82rem;
    font-weight: 500;
    color: var(--sidebar-text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all .15s;
}

.sidebar nav a:hover {
    background: var(--table-hover);
    color: var(--text);
}

.sidebar nav a.active {
    color: var(--sidebar-active);
    background: var(--sidebar-active-bg);
    border-left-color: var(--sidebar-active);
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--border);
}

.main-content {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

/* --- Tab Pages --- */
.tab-page {
    display: none;
    animation: fadeIn .2s;
}

.tab-page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .5rem;
}

.page-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
}

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    transition: background .3s, border .3s;
}

.card-title {
    font-size: .85rem;
    font-weight: 700;
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* --- Stats --- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    background: var(--stat-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: .72rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-top: .15rem;
}

/* --- Form Elements --- */
.form-row {
    display: flex;
    gap: .75rem;
    margin-bottom: .5rem;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 0;
    margin-bottom: .6rem;
}

.form-label {
    display: block;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: .25rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: .55rem .75rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    color: var(--text);
    font-size: .85rem;
    font-family: inherit;
    outline: none;
    transition: border .2s, box-shadow .2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus {
    box-shadow: 0 0 0 3px rgba(108, 92, 231, .2);
}

.form-textarea {
    resize: vertical;
    min-height: 60px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .45rem .9rem;
    border: none;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent2);
    box-shadow: 0 2px 8px rgba(59, 130, 246, .25);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    opacity: .9;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    opacity: .9;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-outline:hover {
    background: var(--table-hover);
    border-color: var(--text-dim);
    color: var(--text);
}

.btn-sm {
    padding: .3rem .6rem;
    font-size: .75rem;
}

.btn-group {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

/* --- Tables --- */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--card-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

thead {
    background: var(--table-header);
}

th {
    padding: .55rem .7rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-dim);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: .5rem .7rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

tr:nth-child(even) {
    background: var(--table-stripe);
}

tr:hover {
    background: var(--table-hover);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    padding: .12rem .45rem;
    border-radius: 100px;
    font-size: .7rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-muted {
    background: rgba(128, 128, 128, .1);
    color: var(--text-dim);
}

/* --- Log Panel --- */
.log-panel {
    background: var(--log-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem 1rem;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: .78rem;
    color: var(--text-muted);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
}

/* --- Progress --- */
.progress-bar {
    height: 8px;
    background: var(--progress-bg);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--progress-fill);
    border-radius: 4px;
    transition: width .3s;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: .5rem;
}

.toast {
    padding: .7rem 1.2rem;
    border-radius: 10px;
    background: var(--toast-bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: .82rem;
    font-weight: 500;
    color: var(--text);
    animation: toastIn .3s;
    min-width: 200px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

@keyframes toastIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* --- Spinner --- */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Theme Toggle Button --- */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .8rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: .75rem;
    color: var(--text-muted);
    font-family: inherit;
    transition: all .2s;
}

.theme-toggle:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

/* --- Result feedback --- */
.result {
    padding: .75rem 1rem;
    border-radius: 10px;
    font-size: .85rem;
    font-weight: 500;
    display: none;
    line-height: 1.5;
}

.result-success {
    display: block;
    background: rgba(22, 163, 74, .08);
    color: var(--success);
    border: 1px solid rgba(22, 163, 74, .15);
}

.result-error {
    display: block;
    background: rgba(220, 38, 38, .08);
    color: var(--error);
    border: 1px solid rgba(220, 38, 38, .15);
}

/* --- Progress bar --- */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2, #60a5fa));
    border-radius: 99px;
    transition: width .3s ease;
}

/* --- Worker Cards (Concurrent Registration) --- */
.worker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .5rem;
}

.worker-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .6rem .8rem;
    background: var(--bg);
    transition: border-color .3s, box-shadow .3s;
}

.worker-card.working {
    border-color: var(--accent, #3b82f6);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.worker-card.done {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.05);
}

.worker-card.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.worker-id {
    font-weight: 700;
    font-size: .9rem;
    color: var(--text);
    margin-bottom: .25rem;
}

.worker-status {
    font-size: .8rem;
    color: var(--text-secondary);
    margin-bottom: .15rem;
}

.worker-email {
    font-size: .75rem;
    color: var(--text-muted);
    font-family: Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}