/* ── CertiLead Sandbox ── */

:root {
    --sb-primary: #0d6efd;
    --sb-primary-dark: #0a58ca;
    --sb-bg: #f5f6fa;
    --sb-card-bg: #ffffff;
    --sb-header-bg: #1a1d23;
    --sb-text: #2d3748;
    --sb-text-muted: #6c757d;
    --sb-border: #e2e8f0;
    --sb-success: #198754;
    --sb-success-bg: #d1e7dd;
    --sb-radius: 12px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--sb-bg);
    color: var(--sb-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
.sb-header {
    background: var(--sb-header-bg);
    padding: 1rem 0;
}

.sb-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sb-logo {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sb-logo i { font-size: 1.5rem; color: var(--sb-primary); }
.sb-logo small { font-weight: 500; margin-left: 0.25rem; color: #efad11; }

.sb-badge-env {
    background: #ffc107;
    color: #000;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

/* ── Hero ── */
.sb-hero {
    text-align: center;
    padding: 3rem 0 2rem;
}

.sb-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.sb-hero p {
    color: var(--sb-text-muted);
    font-size: 1.1rem;
}

/* ── Cards grid ── */
.sb-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding-bottom: 3rem;
}

.sb-card {
    background: var(--sb-card-bg);
    border: 1px solid var(--sb-border);
    border-radius: var(--sb-radius);
    padding: 1.75rem;
    transition: box-shadow 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}

.sb-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.sb-card-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.sb-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.sb-card p {
    color: var(--sb-text-muted);
    font-size: 0.9rem;
    flex: 1;
}

.sb-card-badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.sb-card-badge.multi {
    background: #e0e7ff;
    color: #3730a3;
}

.sb-card-badge.single {
    background: #d1fae5;
    color: #065f46;
}

/* ── Form page ── */
.sb-form-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.sb-form-header {
    margin-bottom: 2rem;
}

.sb-form-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.sb-form-header p {
    color: var(--sb-text-muted);
}

.sb-form-card {
    background: var(--sb-card-bg);
    border: 1px solid var(--sb-border);
    border-radius: var(--sb-radius);
    padding: 2rem;
}

.sb-form-card .form-label {
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
}

.sb-form-card .form-control,
.sb-form-card .form-select {
    border-radius: 8px;
    border: 1px solid var(--sb-border);
    padding: 0.6rem 0.85rem;
}

.sb-form-card .form-control:focus,
.sb-form-card .form-select:focus {
    border-color: var(--sb-primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

.sb-consent {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.sb-consent .form-check-label {
    font-size: 0.85rem;
    color: var(--sb-text-muted);
}

/* ── Stepper ── */
.sb-stepper-bar {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
}

.sb-stepper-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--sb-text-muted);
    font-weight: 500;
}

.sb-stepper-item + .sb-stepper-item::before {
    content: '';
    display: block;
    width: 40px;
    height: 2px;
    background: var(--sb-border);
    margin-right: 0.5rem;
}

.sb-stepper-item .sb-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--sb-border);
    color: var(--sb-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.sb-stepper-item.active { color: var(--sb-primary); }
.sb-stepper-item.active .sb-step-num {
    background: var(--sb-primary);
    color: #fff;
}

.sb-stepper-item.done { color: var(--sb-success); }
.sb-stepper-item.done .sb-step-num {
    background: var(--sb-success);
    color: #fff;
}

.sb-stepper-item.done + .sb-stepper-item::before,
.sb-stepper-item.active + .sb-stepper-item::before {
    background: var(--sb-success);
}

.sb-step-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--sb-border);
}

/* ── Success page ── */
.sb-success {
    text-align: center;
    max-width: 600px;
    margin: 3rem auto;
    padding: 3rem 2rem;
    background: var(--sb-card-bg);
    border: 1px solid var(--sb-border);
    border-radius: var(--sb-radius);
}

.sb-success-icon {
    font-size: 4rem;
    color: var(--sb-success);
    margin-bottom: 1rem;
}

.sb-success h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.sb-success .sb-token {
    display: inline-block;
    background: #f1f5f9;
    border: 1px solid var(--sb-border);
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 500;
    margin: 1rem 0;
    word-break: break-all;
}

.sb-success-links {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

/* ── Footer ── */
.sb-footer {
    margin-top: auto;
    background: var(--sb-header-bg);
    color: rgba(255,255,255,0.5);
    padding: 1rem 0;
    font-size: 0.8rem;
    text-align: center;
}

/* ── Hub ── */
.sb-hub {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    padding-bottom: 3rem;
    max-width: 1100px;
    margin: 0 auto;
}

.sb-hub-card {
    background: var(--sb-card-bg);
    border: 1px solid var(--sb-border);
    border-radius: var(--sb-radius);
    padding: 2.5rem;
    text-decoration: none;
    color: var(--sb-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

.sb-hub-card:hover {
    box-shadow: 0 12px 32px rgba(0,0,0,0.1);
    transform: translateY(-3px);
    border-color: var(--sb-primary);
    color: var(--sb-text);
}

.sb-hub-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: #e0e7ff;
    color: #3730a3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-bottom: 1.25rem;
}

.sb-hub-icon--verify {
    background: #fef3c7;
    color: #92400e;
}

.sb-hub-icon--rrweb {
    background: #dbeafe;
    color: #1e40af;
}

.sb-hub-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.sb-hub-card p {
    color: var(--sb-text-muted);
    font-size: 0.9rem;
    flex: 1;
}

.sb-hub-action {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--sb-primary);
    margin-top: 1rem;
}

/* ── Verify Tool ── */
.sb-verify-page {
    padding: 2rem 0 3rem;
}

.sb-verify-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.sb-verify-input .sb-form-card h5 {
    font-size: 1rem;
    font-weight: 600;
}

/* Console */
.sb-verify-console {
    background: #1a1d23;
    border-radius: var(--sb-radius);
    border: 1px solid #2d3748;
    overflow: hidden;
    min-height: 560px;
    display: flex;
    flex-direction: column;
}

.sb-console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: #111318;
    border-bottom: 1px solid #2d3748;
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
}

.sb-console-btn {
    background: none;
    border: 1px solid #374151;
    color: #94a3b8;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: background 0.15s, color 0.15s;
}

.sb-console-btn:hover {
    background: #374151;
    color: #e2e8f0;
}

.sb-console-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sb-console-body {
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.6;
    color: #e2e8f0;
    overflow-y: auto;
    flex: 1;
    max-height: 75vh;
    scrollbar-width: thin;
    scrollbar-color: #374151 transparent;
}

.sb-console-body::-webkit-scrollbar {
    width: 6px;
}

.sb-console-body::-webkit-scrollbar-track {
    background: transparent;
}

.sb-console-body::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 3px;
}

.sb-console-body::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

.sb-console-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    color: #4b5563;
    text-align: center;
}

.sb-console-placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Console entry */
.sb-console-entry + .sb-console-entry {
    border-top: 1px solid #2d3748;
    margin-top: 1rem;
    padding-top: 1rem;
}

.sb-console-entry-num {
    color: #4b5563;
    font-size: 0.7rem;
    margin-bottom: 0.4rem;
}

.sb-console-curl {
    background: #111318;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    white-space: pre-wrap;
    word-break: break-all;
    color: #a5b4fc;
    font-size: 0.75rem;
    border: 1px solid #1e2530;
}

.sb-console-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
}

.sb-console-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.sb-status-2xx { color: #4ade80; }
.sb-status-4xx { color: #fb923c; }
.sb-status-5xx { color: #f87171; }

.sb-console-details {
    margin-top: 0.5rem;
}

.sb-console-details summary {
    cursor: pointer;
    color: #64748b;
    font-size: 0.72rem;
    padding: 0.3rem 0;
    user-select: none;
}

.sb-console-details summary:hover {
    color: #94a3b8;
}

.sb-console-json {
    background: #0f1117;
    border-radius: 6px;
    padding: 0.75rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 0.72rem;
    margin-top: 0.4rem;
    border: 1px solid #1e2530;
    max-height: 400px;
    overflow-y: auto;
}

/* JSON syntax highlighting */
.sb-json-key { color: #93c5fd; }
.sb-json-string { color: #86efac; }
.sb-json-number { color: #fbbf24; }
.sb-json-bool { color: #c084fc; }
.sb-json-null { color: #6b7280; }

/* Console error */
.sb-console-error {
    background: #2d1b1b;
    border: 1px solid #7f1d1d;
    border-radius: 6px;
    padding: 0.75rem;
    color: #fca5a5;
}

/* Summary section */
.sb-console-summary {
    background: #111318;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid #1e2530;
}

.sb-console-summary h6 {
    color: #94a3b8;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.sb-summary-header {
    padding: 0.4rem 0;
    font-weight: 500;
}

.sb-summary-msg {
    font-weight: 400;
    font-size: 0.72rem;
    margin-top: 0.25rem;
    opacity: 0.8;
}

.sb-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
    border-bottom: 1px solid #1e2530;
}

.sb-summary-row:last-child {
    border-bottom: none;
}

.sb-summary-label { color: #94a3b8; }
.sb-summary-value { font-weight: 500; }
.sb-summary-ok { color: #4ade80; }
.sb-summary-fail { color: #f87171; }
.sb-summary-warn { color: #fb923c; }
.sb-summary-na { color: #6b7280; }

/* ── rrweb Viewer ── */
.sb-rrweb-page {
    padding: 2rem 0 3rem;
}

.sb-rrweb-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.sb-rrweb-input .sb-form-card h5 {
    font-size: 1rem;
    font-weight: 600;
}

#rw_player_container .rr-player {
    max-width: 100% !important;
}

#rw_player_container .rr-player__frame {
    max-width: 100% !important;
}

.sb-rrweb-error {
    background: #2d1b1b;
    border: 1px solid #7f1d1d;
    border-radius: 6px;
    padding: 1rem 1.25rem;
    color: #fca5a5;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    max-width: 500px;
    text-align: center;
}

.sb-rrweb-loading {
    text-align: center;
    color: #94a3b8;
}

.sb-rrweb-loading .spinner-border {
    width: 2rem;
    height: 2rem;
    margin-bottom: 0.75rem;
}

.sb-rrweb-meta-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--sb-border);
    font-size: 0.85rem;
}

.sb-rrweb-meta-row:last-child {
    border-bottom: none;
}

.sb-rrweb-meta-label {
    color: var(--sb-text-muted);
}

.sb-rrweb-meta-value {
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

/* ── Responsive ── */
@media (max-width: 992px) {
    .sb-verify-layout { grid-template-columns: 1fr; }
    .sb-verify-console { min-height: 400px; }
    .sb-rrweb-layout { grid-template-columns: 1fr; }
    .sb-hub { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sb-hero h1 { font-size: 1.5rem; }
    .sb-cards { grid-template-columns: 1fr; }
    .sb-hub { grid-template-columns: 1fr; }
    .sb-form-card { padding: 1.25rem; }
    .sb-stepper-item span:not(.sb-step-num) { display: none; }
    .sb-stepper-item + .sb-stepper-item::before { width: 24px; }
}
