/* ============================================================
   PIX Extractor — UI v2
   ============================================================ */

:root {
    --bg: #0a0c12;
    --bg-elevated: #12151f;
    --card-bg: rgba(22, 26, 38, 0.82);
    --card-border: rgba(255, 255, 255, 0.06);
    --card-border-hover: rgba(16, 185, 129, 0.22);
    --text: #e8eaf2;
    --text-dim: #8b90a8;
    --accent: #10b981;
    --accent-2: #34d399;
    --accent-dim: rgba(16, 185, 129, 0.12);
    --accent-border: rgba(16, 185, 129, 0.28);
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.1);
    --warning: #fbbf24;
    --purple: #a78bfa;
    --blue: #60a5fa;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.bg-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(16, 185, 129, 0.14), transparent 55%),
        radial-gradient(ellipse 40% 30% at 100% 50%, rgba(52, 211, 153, 0.05), transparent 50%),
        radial-gradient(ellipse 30% 25% at 0% 80%, rgba(96, 165, 250, 0.04), transparent 50%);
}

.container {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 28px 18px 56px;
}

/* ============ Header ============ */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
    padding: 8px 0 4px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    display: flex;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 12px rgba(16, 185, 129, 0.35));
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    background: linear-gradient(135deg, #34d399 0%, #10b981 50%, #6ee7b7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 12.5px;
    color: var(--text-dim);
    margin-top: 2px;
}

.header-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stat-pill {
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    color: var(--text-dim);
}

.stat-pill.stat-plus {
    color: var(--accent-2);
    border-color: var(--accent-border);
    background: var(--accent-dim);
}

.stat-pill.stat-ok {
    color: var(--accent-2);
    border-color: var(--accent-border);
    background: var(--accent-dim);
}

.stat-pill.stat-fail {
    color: var(--error);
    border-color: rgba(248, 113, 113, 0.28);
    background: rgba(248, 113, 113, 0.1);
}

.stat-pill.stat-rate {
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.3);
    background: rgba(96, 165, 250, 0.1);
    font-variant-numeric: tabular-nums;
}

.stat-pill.stat-rate.high {
    color: var(--accent-2);
    border-color: var(--accent-border);
    background: var(--accent-dim);
}

.stat-pill.stat-rate.mid {
    color: var(--warning);
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.1);
}

.stat-pill.stat-rate.low {
    color: var(--error);
    border-color: rgba(248, 113, 113, 0.28);
    background: rgba(248, 113, 113, 0.1);
}

.stat-pill.stat-key.ok {
    color: var(--accent-2);
    border-color: var(--accent-border);
    background: var(--accent-dim);
}

.stat-pill.stat-key.warn {
    color: var(--warning);
    border-color: rgba(251, 191, 36, 0.25);
    background: rgba(251, 191, 36, 0.08);
}

.stats-line {
    margin-top: 6px !important;
    color: var(--text-muted, var(--text-dim));
    font-variant-numeric: tabular-nums;
}

/* ============ Cards ============ */

.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    transition: border-color 0.2s, box-shadow 0.2s;
    animation: fadeIn 0.35s ease;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.card-header h2 {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -0.2px;
}

.card-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
    font-weight: 400;
}

.count-badge {
    min-width: 28px;
    height: 28px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--accent-dim);
    color: var(--accent-2);
    border: 1px solid var(--accent-border);
}

/* ============ Secure / API Key panel ============ */

.card-secure {
    padding: 0;
    overflow: hidden;
}

.secure-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.15s;
}

.secure-toggle:hover {
    background: rgba(255, 255, 255, 0.02);
}

.secure-toggle-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.secure-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(167, 139, 250, 0.12);
    border: 1px solid rgba(167, 139, 250, 0.2);
    font-size: 18px;
    flex-shrink: 0;
}

.secure-title {
    font-size: 14px;
    font-weight: 650;
}

.secure-desc {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 1px;
}

.secure-toggle-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.key-status {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.key-status.off {
    background: rgba(251, 191, 36, 0.1);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.22);
}

.key-status.on {
    background: var(--accent-dim);
    color: var(--accent-2);
    border: 1px solid var(--accent-border);
}

.chevron {
    color: var(--text-dim);
    font-size: 12px;
    transition: transform 0.2s;
}

.secure-toggle[aria-expanded="true"] .chevron,
details[open] > summary .chevron {
    transform: rotate(180deg);
}

.secure-body {
    padding: 0 20px 20px;
    border-top: 1px solid var(--card-border);
    animation: fadeIn 0.25s ease;
}

.secure-body[hidden] {
    display: none !important;
}

.secure-warn {
    margin: 14px 0 16px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--purple);
    background: rgba(167, 139, 250, 0.08);
    border: 1px solid rgba(167, 139, 250, 0.18);
    border-radius: var(--radius-sm);
    line-height: 1.45;
}

.secret-field {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.secret-field input {
    flex: 1;
    min-width: 0;
}

/* ============ Form ============ */

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 7px;
    color: var(--text);
}

textarea,
input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 11px 13px;
    font-size: 13px;
    font-family: var(--mono);
    color: var(--text);
    background: rgba(8, 10, 16, 0.85);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

textarea {
    resize: vertical;
    min-height: 88px;
    line-height: 1.5;
}

textarea::placeholder,
input::placeholder {
    color: #5a5f78;
}

.help-text {
    font-size: 11.5px;
    color: var(--text-dim);
    margin-top: 6px;
    line-height: 1.45;
}

.help-text code {
    color: var(--accent-2);
    background: var(--accent-dim);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--mono);
}

.help-text a {
    color: var(--accent-2);
}

.check-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-dim);
    user-select: none;
}

.check-label input {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* ============ Buttons ============ */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 20px;
    font-size: 14.5px;
    font-weight: 650;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.2s, opacity 0.15s;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
}

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

.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary.loading .btn-icon {
    animation: spin 1s linear infinite;
}

.btn-sm {
    width: auto;
    padding: 9px 14px;
    font-size: 13px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--accent-2);
    background: var(--accent-dim);
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.4);
}

.btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 550;
    font-family: inherit;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.btn-ghost.danger-text,
.danger-text {
    color: #f87171 !important;
}

.btn-ghost.danger-text:hover {
    background: rgba(248, 113, 113, 0.1);
}

.btn-icon {
    font-size: 13px;
    display: inline-flex;
}

/* ============ Details (advanced) ============ */

.card-details {
    padding: 0;
}

.card-details > summary {
    list-style: none;
}

.card-details > summary::-webkit-details-marker {
    display: none;
}

.details-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-dim);
    user-select: none;
    transition: color 0.15s, background 0.15s;
}

.details-summary:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.02);
}

.details-body {
    padding: 4px 20px 20px;
    border-top: 1px solid var(--card-border);
}

/* ============ Accounts ============ */

.accounts-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    align-items: center;
}

.accounts-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    background: rgba(8, 10, 16, 0.6);
}

.accounts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.accounts-table th {
    text-align: left;
    padding: 11px 12px;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.015);
    white-space: nowrap;
}

.accounts-table td {
    padding: 11px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.accounts-table tbody tr {
    transition: background 0.12s;
}

.accounts-table tbody tr:hover {
    background: rgba(16, 185, 129, 0.04);
}

.accounts-table tr:last-child td {
    border-bottom: none;
}

.accounts-table .empty-row td {
    color: var(--text-dim);
    text-align: center;
    padding: 28px 16px;
    font-style: italic;
    font-size: 13px;
}

.accounts-table .time-cell {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 118px;
}

.accounts-table .email-cell {
    font-weight: 550;
    word-break: break-all;
    max-width: 240px;
    font-size: 12.5px;
}

.accounts-table .token-mask {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    opacity: 0.75;
}

.accounts-table .row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.accounts-table .row-actions button {
    font-size: 11.5px;
    font-weight: 600;
    font-family: inherit;
    padding: 5px 9px;
    border-radius: 7px;
    cursor: pointer;
    border: 1px solid var(--accent-border);
    background: var(--accent-dim);
    color: var(--accent-2);
    transition: background 0.12s;
}

.accounts-table .row-actions button:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.22);
}

.accounts-table .row-actions button.danger {
    border-color: rgba(248, 113, 113, 0.28);
    background: rgba(248, 113, 113, 0.08);
    color: #f87171;
}

.accounts-table .row-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.status-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.status-badge.pending { background: rgba(136, 140, 166, 0.15); color: #a1a5c0; }
.status-badge.extracting { background: rgba(96, 165, 250, 0.14); color: var(--blue); }
.status-badge.ready { background: rgba(251, 191, 36, 0.12); color: var(--warning); }
.status-badge.submitted { background: rgba(167, 139, 250, 0.14); color: var(--purple); }
.status-badge.plus { background: rgba(16, 185, 129, 0.16); color: var(--accent-2); }
.status-badge.failed { background: rgba(248, 113, 113, 0.12); color: var(--error); }

/* ============ Progress / Log ============ */

.progress-bar-container {
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 14px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 4px;
    transition: width 0.35s ease;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.log-container {
    background: rgba(8, 10, 16, 0.75);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    max-height: 340px;
    overflow-y: auto;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.65;
}

.log-container::-webkit-scrollbar { width: 6px; }
.log-container::-webkit-scrollbar-track { background: transparent; }
.log-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

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

.log-line {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.025);
    word-break: break-word;
    animation: fadeIn 0.18s ease;
}

.log-line:last-child { border-bottom: none; }

.log-line.step { color: var(--blue); }
.log-line.success { color: var(--accent-2); }
.log-line.error { color: var(--error); }
.log-line.info { color: var(--text); }
.log-line.result { color: var(--accent-2); font-weight: 600; }
.log-line.skip { color: var(--text-dim); }
.log-line.warning { color: var(--warning); }

/* ============ Result ============ */

.result-card {
    border-color: rgba(16, 185, 129, 0.25);
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.08), var(--shadow);
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-dim);
    margin-top: 4px;
}

.result-url-wrapper {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.result-url {
    flex: 1;
    padding: 12px 14px;
    background: rgba(8, 10, 16, 0.75);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-family: var(--mono);
    word-break: break-all;
    white-space: pre-wrap;
    color: var(--accent-2);
    line-height: 1.5;
    min-height: 44px;
}

.result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.qr-img {
    max-width: 200px;
    background: #fff;
    padding: 10px;
    border-radius: 12px;
    display: block;
}

/* ============ Error ============ */

.error-card {
    border-color: rgba(248, 113, 113, 0.25);
}

.error-message {
    padding: 12px 14px;
    background: var(--error-bg);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 13.5px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* ============ Footer ============ */

.footer {
    text-align: center;
    padding-top: 20px;
    color: var(--text-dim);
    font-size: 11.5px;
    opacity: 0.65;
}

/* ============ Utilities ============ */

[hidden] {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
