/* Theme toggle */
.theme-toggle {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 100;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    border-color: var(--accent);
    box-shadow: var(--accent-glow);
    transform: translateY(-1px);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Inline toggle inside admin nav */
.header-nav .theme-toggle {
    position: static;
    display: inline-flex;
}

/* Light theme palette */
html[data-theme="light"] {
    --bg: #f2f2f5;
    --bg-card: #ffffff;
    --bg-input: #ebebee;
    --text: #1a1a20;
    --text-muted: #5d5d68;
    --accent: #00935a;
    --accent-hover: #007a4b;
    --accent-gradient: linear-gradient(90deg, #00a866, #007a4b);
    --accent-glow: 0 10px 25px rgba(0, 147, 90, 0.25);
    --accent-soft: rgba(0, 147, 90, 0.08);
    --border: #d8d8de;
    --border-hover: #00935a;
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.08);
}

html[data-theme="dark"],
:root {
    --accent-soft: rgba(0, 255, 157, 0.06);
}

/* Auth pages */
.auth-body {
    justify-content: center;
    align-items: center;
}

.auth-page {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-card);
    text-align: center;
}

.auth-logo {
    margin-bottom: 20px;
}

.auth-title {
    margin-bottom: 24px;
    font-size: 1.8rem;
}

.auth-form {
    text-align: left;
}

.auth-links {
    margin-top: 16px;
    font-size: 0.95rem;
}

.auth-links a {
    color: var(--accent);
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.alert-error {
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.alert-success {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.btn-primary {
    background: var(--accent);
    color: #000;
    border-color: transparent;
}

.btn-primary:hover {
    box-shadow: var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.22);
    border-color: rgba(248, 113, 113, 0.5);
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-sm {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-sm:hover {
    border-color: var(--border-hover);
}

.btn-sm.btn-danger {
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-card);
    margin-bottom: 25px;
}

.card-title {
    font-size: 1.3rem;
    margin-bottom: 16px;
}

/* Page title */
.page-title {
    font-size: 1.8rem;
    margin-bottom: 24px;
}

/* Landing layout */
.upload-card {
    max-width: 720px;
    margin: 0 auto;
}

.dz-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    margin-bottom: 14px;
}

.dz-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.dz-browse {
    color: var(--accent);
    text-decoration: underline;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.pill {
    font-size: 0.82rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 4px 12px;
    background: var(--bg-input);
}

.steps {
    max-width: 720px;
    margin: 10px auto 30px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.step {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px 18px;
    text-align: center;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    font-weight: 700;
    margin-bottom: 10px;
}

.step h3 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.step p {
    font-size: 0.88rem;
}

.code-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
    margin-top: 18px;
}

.code-row .code-display {
    flex: 1;
}

/* File items */
.file-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Code display */
.code-display {
    background: var(--bg-input);
    border: 2px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    text-align: center;
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 8px;
    color: var(--accent);
    font-family: var(--font-mono);
}

/* Token display */
.token-display {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    word-break: break-all;
    color: var(--accent);
}

/* Tables */
.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.table th {
    color: var(--text-muted);
    font-weight: 600;
}

.inline-form {
    display: inline;
}

/* Badges */
.badge-on {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.85rem;
}

.badge-off {
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.85rem;
}

.badge-warn {
    background: rgba(255, 183, 77, 0.15);
    color: #ffb74d;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.85rem;
}

/* Header */
.site-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -20px -20px 30px;
}

.header-inner {
    display: flex;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo {
    background: var(--accent);
    color: #000;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.brand-name {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 600;
    font-size: 1.1rem;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-link:hover {
    color: var(--accent);
}

.nav-user {
    color: var(--text-muted);
    font-size: 0.9rem;
    border-left: 1px solid var(--border);
    padding-left: 16px;
}

/* App main */
.app-main {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-zone:hover,
.upload-zone.drag-active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.upload-zone input[type="file"] {
    display: none;
}

/* Progress */
.progress-container {
    height: 8px;
    background: var(--bg-input);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    transition: width 0.4s ease;
}

/* Light-mode accent fixes */
html[data-theme="light"] .btn-primary,
html[data-theme="light"] .step-num,
html[data-theme="light"] .logo {
    color: #fff;
}

html[data-theme="light"] .badge-warn {
    color: #8a5a00;
    background: rgba(255, 183, 77, 0.25);
}

/* Responsive */
@media (max-width: 720px) {
    .site-header {
        flex-direction: column;
        gap: 12px;
    }

    .header-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .code-display {
        font-size: 1.6rem;
        letter-spacing: 4px;
    }

    .code-row {
        flex-direction: column;
    }

    .steps {
        grid-template-columns: 1fr;
    }
}
