/* Standalone pages: login, register, email verification, crawl history and
 * the memory debug page. Loaded after styles.css, which supplies the tokens,
 * the reset, buttons and table styling. Everything here is scoped under a
 * body class so it cannot leak into the app shell, and so class names these
 * pages share with the shell (.metric, .table-container, .btn) can differ.
 */

body.page {
    min-height: 100dvh;
    overflow: auto;
}

/* --- Auth pages --------------------------------------------------------- */

.page-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
}

.auth-card .logo {
    margin-bottom: 28px;
}

.auth-card .logo img {
    display: block;
    height: 36px;
    width: auto;
    margin-bottom: 10px;
}

.auth-card .logo p {
    color: var(--text-2);
}

.page-auth .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.page-auth label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.page-auth input[type="text"],
.page-auth input[type="email"],
.page-auth input[type="password"] {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
}

.page-auth input:hover {
    border-color: var(--text-3);
}

.page-auth input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-hint {
    font-size: 12px;
    color: var(--text-2);
}

.page-auth .btn {
    width: 100%;
    height: 40px;
    margin-top: 8px;
    font-size: 14px;
}

.register-link,
.login-link {
    margin-top: 20px;
    color: var(--text-2);
}

.register-link a,
.login-link a {
    color: var(--accent-text);
    font-weight: 500;
    text-decoration: none;
}

.register-link a:hover,
.login-link a:hover {
    text-decoration: underline;
}

.alert {
    display: none;
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--tone) 40%, transparent);
    border-radius: var(--r);
    background: color-mix(in srgb, var(--tone) 12%, transparent);
    color: var(--text);
    font-size: 13px;
    --tone: var(--info);
}

.alert.show {
    display: block;
}

.alert strong {
    display: block;
}

.alert-error { --tone: var(--err); }
.alert-success { --tone: var(--ok); }
.alert-info { --tone: var(--info); }

/* --- Email verification ------------------------------------------------- */

.verify-card {
    text-align: left;
}

.verify-card .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--tone) 16%, transparent);
    color: var(--tone);
    font-size: 20px;
    font-weight: 600;
}

.verify-card .icon.success { --tone: var(--ok); }
.verify-card .icon.error { --tone: var(--err); }

.verify-card h1 {
    margin-bottom: 8px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.verify-card .message {
    margin-bottom: 20px;
    color: var(--text-2);
}

.auto-redirect {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-2);
}

.auto-redirect .spinner {
    margin-left: 8px;
    vertical-align: -2px;
}

.page .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent-soft);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: busy-spin 0.9s linear infinite;
}

/* --- Full pages (crawl history, memory debug) --------------------------- */

.page-wide .container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 24px;
    margin-bottom: 20px;
}

.page-head h1 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.page-head p {
    margin-top: 2px;
    color: var(--text-2);
}

/* Figures as one ruled strip, the same treatment as the app's stat strip. */
.stats-grid,
.summary-cards {
    display: flex;
    flex-wrap: wrap;
    overflow: hidden;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}

.stat-card,
.summary-card {
    flex: 1 0 160px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-left: -1px;
    padding: 12px 16px;
    border-left: 1px solid var(--border);
}

.stat-card .stat-value,
.summary-card .value {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.summary-card h3 {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-3);
}

.summary-card .label {
    font-size: 12px;
    color: var(--text-2);
}

.page-wide .table-container {
    flex: none;
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}

.page-wide table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.page-wide th {
    height: 34px;
    padding: 0 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-strong);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.page-wide td {
    height: 44px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

.page-wide tbody tr:last-child td {
    border-bottom: none;
}

.page-wide tbody tr:hover td {
    background: var(--surface-2);
}

.url-link {
    color: var(--accent-text);
    text-decoration: none;
}

.url-link:hover {
    text-decoration: underline;
}

.page-wide td.loading,
.page-wide td.empty-state {
    display: table-cell;
    height: auto;
    min-height: 0;
    padding: 48px 16px;
    color: var(--text-2);
    text-align: center;
}

.page-wide td.empty-state h3 {
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* --- Memory debug ------------------------------------------------------- */

.refresh-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-2);
}

/* A live indicator: it pulses because the page really is polling. */
.refresh-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    animation: refresh-pulse 2s ease-in-out infinite;
}

@keyframes refresh-pulse {
    50% { opacity: 0.35; }
}

.instances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr));
    gap: 16px;
}

.instance-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.instance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.instance-id {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
}

.instance-badge {
    flex-shrink: 0;
    padding: 0 6px;
    border-radius: var(--r-sm);
    background: color-mix(in srgb, var(--ok) 16%, transparent);
    color: var(--ok);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.page-debug .metric {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.page-debug .metric:nth-child(odd) {
    border-right: 1px solid var(--border);
}

.page-debug .metric-label {
    font-size: 11px;
    color: var(--text-3);
}

.page-debug .metric-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.metric-subtext {
    font-size: 12px;
    color: var(--text-2);
}

.estimates-section {
    padding: 12px 16px;
}

.estimates-title {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
}

.estimate-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
}

.estimate-label {
    color: var(--text-2);
}

.estimate-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.highlight-value { color: var(--ok); }
.warning-value { color: var(--warn); }
.error-value { color: #f87171; }

.page-debug .empty-state {
    grid-column: 1 / -1;
    flex-direction: column;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    color: var(--text-2);
}

@media (max-width: 600px) {
    .auth-card {
        padding: 24px 20px;
    }

    .page-wide .container {
        padding: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .refresh-dot {
        animation: none;
    }
}

.page-debug .metric {
    justify-content: flex-start;
}

/* Google Sign-In. The divider takes theme colours; the button does not.
   Google's branding guidelines fix the button's ground, border and text, and
   require the mark to be unmodified - so this is their dark specification
   verbatim, which is the variant meant for a dark surface like .auth-card. */
.page-auth .divider-rule {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-3);
    font-size: 13px;
}
.page-auth .divider-rule::before,
.page-auth .divider-rule::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.page-auth .btn-google {
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #131314;
    border: 1px solid #8e918f;
    border-radius: var(--r);
    color: #e3e3e3;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s var(--ease), border-color 0.12s var(--ease);
}
.page-auth .btn-google:hover {
    background: #1e1f20;
    border-color: #a8abaa;
}
.page-auth .btn-google:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
