/* auth.css — Auth & Admin UI tokens + component classes
 *
 * Two layers in this file:
 *   1. Tokens (--auth-* / --admin-*) that brand auth/admin pages
 *      without modifying templates. Override these in your app CSS.
 *   2. Component classes (.auth-shell, .auth-card, .admin-header, …)
 *      used by the github.com/jyrobin/auth library's templates.
 *      Apps generally don't need to override these directly; the
 *      tokens above already drive most visual decisions.
 *
 * Usage:
 *   <link rel="stylesheet" href="/static/motif/tokens.css">
 *   <link rel="stylesheet" href="/static/motif/components.css">
 *   <link rel="stylesheet" href="/static/motif/auth.css">
 *
 * To customize, override any --auth-* or --admin-* variable in your
 * app CSS:
 *   :root { --auth-bg: #1a1a2e; --auth-accent: #e94560; }
 */

:root {
    /* ── Public Auth Pages ─────────────────────────────────── */

    /* Page background (gradient or solid) */
    --auth-bg: linear-gradient(135deg, var(--color-primary-500) 0%, var(--color-secondary-600) 100%);

    /* Card appearance */
    --auth-card-bg: var(--color-card-bg);
    --auth-card-shadow: var(--shadow-xl);
    --auth-card-radius: var(--radius-xl);
    --auth-card-padding: var(--space-10);
    --auth-card-width: 400px;
    --auth-card-width-wide: 500px;

    /* Asymmetric card padding — defaults to the uniform value so
       behavior is unchanged. Voices that want more vertical
       breathing room than horizontal (quieter feel) override these. */
    --auth-card-padding-y: var(--auth-card-padding);
    --auth-card-padding-x: var(--auth-card-padding);

    /* Title (logo fallback text) */
    --auth-title-color: var(--color-fg);
    --auth-title-size: var(--text-2xl);

    /* Title typography knobs — defaults match the original
       `<h1>` styling (motif's --font-sans + semibold + tight).
       Voices that want a serif display title or different
       weight/tracking override these. */
    --auth-title-font: var(--font-sans);
    --auth-title-weight: var(--font-semibold);
    --auth-title-tracking: var(--tracking-tight);

    /* Descriptive text */
    --auth-text-color: var(--color-fg-muted);

    /* Primary action buttons (Sign In, Create Account, etc.) */
    --auth-action-bg: linear-gradient(135deg, var(--color-primary-500) 0%, var(--color-secondary-600) 100%);
    --auth-action-color: #fff;
    --auth-action-radius: var(--radius-lg);

    /* Input style — voices choose between boxed (default, what
       motif's .input does today) and bottom-rule (single line under
       the field). The flag is read by family CSS that wants the
       bottom-rule treatment; motif core itself stays boxed. */
    --auth-input-bottom-only: 0;
    --auth-input-rest-color: var(--color-border);
    --auth-input-focus-color: var(--auth-focus-color);

    /* Links inside the auth-card (forgot password, sign up, etc.) —
       sit on the card surface, so use the brand primary. */
    --auth-link-color: var(--color-primary-500);

    /* Link decoration — defaults to no underline at rest (decoration
       on hover). Voices that want always-on underlines (quieter UI
       signaling) override these. */
    --auth-link-decoration: none;
    --auth-link-underline-offset: 0.2em;

    /* The back-to-site link sits at the bottom of the card. Defaults
       are card-friendly (muted fg / strong fg on hover); families
       can override for their voice. */
    --auth-site-link-color: var(--color-fg-muted);
    --auth-site-link-hover: var(--color-fg);

    /* Input focus state */
    --auth-focus-color: var(--color-primary-500);
    --auth-focus-ring: 0 0 0 3px rgba(102, 126, 234, 0.1);

    /* Error alert */
    --auth-error-bg: var(--color-danger-50);
    --auth-error-border: var(--color-danger-100);
    --auth-error-color: var(--color-danger-600);

    /* Success alert */
    --auth-success-bg: var(--color-success-50);
    --auth-success-border: var(--color-success-100);
    --auth-success-color: var(--color-success-600);

    /* ── Admin Pages ──────────────────────────────────────── */

    /* Page background */
    --admin-bg: var(--color-bg);

    /* Header bar */
    --admin-header-bg: linear-gradient(135deg, var(--color-primary-500) 0%, var(--color-secondary-600) 100%);
    --admin-header-color: #fff;

    /* Accent (search buttons, pagination active, primary actions) */
    --admin-accent: var(--color-primary-500);

    /* Card / table wrapper */
    --admin-card-bg: var(--color-card-bg);
    --admin-card-shadow: var(--shadow-md);
    --admin-card-radius: var(--radius-xl);

    /* Alert (reuses auth tokens by default) */
    --admin-error-bg: var(--auth-error-bg);
    --admin-error-border: var(--auth-error-border);
    --admin-error-color: var(--auth-error-color);
    --admin-success-bg: var(--auth-success-bg);
    --admin-success-border: var(--auth-success-border);
    --admin-success-color: var(--auth-success-color);
}

/* ════════════════════════════════════════════════════════════
 * PUBLIC AUTH COMPONENTS
 * Used by login / register / forgot_password / reset_password /
 * verify_email / logout / profile templates.
 * ════════════════════════════════════════════════════════════ */

/* Page shell — flex-centered column on the brand gradient.
   Templates apply this to <body>. */
.auth-shell {
    background: var(--auth-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-4);
}

/* Card on the gradient. Default 400px wide; .auth-card-wide for
   profile (500px). */
.auth-card {
    background: var(--auth-card-bg);
    border-radius: var(--auth-card-radius);
    box-shadow: var(--auth-card-shadow);
    padding: var(--auth-card-padding);
    width: 100%;
    max-width: var(--auth-card-width);
}
.auth-card-wide { max-width: var(--auth-card-width-wide); }
.auth-card-centered { text-align: center; }

/* Logo block — img if provided, h1 fallback. */
.auth-logo { text-align: center; margin-bottom: var(--space-8); }
.auth-logo img { max-height: 60px; max-width: 200px; }
.auth-logo h1 {
    color: var(--auth-title-color);
    font-size: var(--auth-title-size);
    font-weight: var(--font-semibold);
}

/* Profile uses a horizontal header (logo left, sign-out right). */
.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-8);
}
.auth-header .auth-logo { margin-bottom: 0; }
.auth-header .auth-logo h1 { font-size: var(--text-xl); }
.auth-header .auth-logo img { max-height: 40px; max-width: 150px; }

/* Primary form CTA (Sign In, Register, Reset, etc.). */
.auth-submit {
    width: 100%;
    padding: var(--space-3);
    background: var(--auth-action-bg);
    border: none;
    border-radius: var(--auth-action-radius);
    color: var(--auth-action-color);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: opacity var(--duration-fast) var(--ease-default);
}
.auth-submit:hover { opacity: 0.9; }
.auth-submit:active { transform: scale(0.98); }

/* Single inline-block CTA (verify_email's "Continue to login"). */
.auth-action {
    display: inline-block;
    padding: var(--space-3) var(--space-8);
    background: var(--auth-action-bg);
    border: none;
    border-radius: var(--auth-action-radius);
    color: var(--auth-action-color);
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    text-decoration: none;
    transition: opacity var(--duration-fast) var(--ease-default);
}
.auth-action:hover { opacity: 0.9; }

/* Text blocks under the logo. */
.auth-description {
    color: var(--auth-text-color);
    font-size: var(--text-sm);
    text-align: center;
    margin-bottom: var(--space-6);
    line-height: var(--leading-normal);
}
.auth-message {
    color: var(--auth-text-color);
    font-size: var(--text-base);
    margin-bottom: var(--space-8);
    line-height: var(--leading-normal);
    text-align: center;
}

/* Logout's two-button row (cancel / confirm). */
.auth-buttons { display: flex; gap: var(--space-3); }
.auth-buttons > * { flex: 1; }
.auth-buttons .btn-logout {
    background: var(--color-danger-600);
    border: none;
    color: #fff;
}
.auth-buttons .btn-logout:hover { background: var(--color-danger-700); }

/* Verify email's success / error glyph. */
.auth-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: var(--space-4);
}
.auth-icon.success { color: var(--color-success-600); }
.auth-icon.error { color: var(--color-danger-600); }

/* Login's "remember me" checkbox row. */
.remember-me {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-6);
}
.remember-me input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: var(--space-2);
    cursor: pointer;
}
.remember-me label {
    color: var(--auth-text-color);
    font-size: var(--text-sm);
    cursor: pointer;
}

/* Secondary action links (forgot password, sign up, has account, …). */
.auth-links { text-align: center; margin-top: var(--space-4); }
.auth-links a {
    color: var(--auth-link-color);
    text-decoration: none;
    font-size: var(--text-sm);
}
.auth-links a:hover { text-decoration: underline; }

/* Locale picker at card foot. */
.lang-switcher { text-align: center; margin-top: var(--space-4); font-size: var(--text-xs); }
.lang-switcher a {
    color: var(--auth-link-color);
    text-decoration: none;
    margin: 0 var(--space-1);
}
.lang-switcher a:hover { text-decoration: underline; }
.lang-switcher a.active { font-weight: var(--font-semibold); }

/* Back-to-site link sitting at the bottom of the card, after the
   lang-switcher. Was previously placed outside the card on a brand
   gradient; the inside-card position reclaims vertical space and
   gives the link a quieter "footer" role. */
.auth-site-link { text-align: center; margin-top: var(--space-4); }
.auth-site-link a {
    color: var(--auth-site-link-color);
    text-decoration: none;
    font-size: var(--text-sm);
}
.auth-site-link a:hover {
    color: var(--auth-site-link-hover);
    text-decoration: underline;
}

/* ─── Profile-page extras ──────────────────────────────── */

.section-title {
    color: var(--auth-title-color);
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: var(--border-1) solid var(--color-border);
}

.info-group { margin-bottom: var(--space-4); }

.role-badge {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    background: var(--color-primary-100);
    color: var(--color-primary-700);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    text-transform: uppercase;
}

/* Avatar block on profile page. */
.avatar-section {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.avatar-wrapper { position: relative; width: 80px; height: 80px; flex-shrink: 0; }
.avatar-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: var(--border-2) solid var(--color-border);
}
.avatar-initials {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--auth-action-bg);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: var(--font-semibold);
    border: var(--border-2) solid var(--color-border);
}
.avatar-overlay {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 28px;
    height: 28px;
    background: var(--auth-card-bg);
    border: var(--border-1) solid var(--color-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--duration-fast);
}
.avatar-overlay:hover { background: var(--color-neutral-100); }
.avatar-overlay svg { width: 14px; height: 14px; fill: var(--color-fg); }
.avatar-delete-btn {
    padding: var(--space-1) var(--space-3);
    background: none;
    border: var(--border-1) solid var(--color-danger-100);
    border-radius: var(--radius-md);
    color: var(--color-danger-600);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: background var(--duration-fast);
}
.avatar-delete-btn:hover { background: var(--color-danger-50); }

/* ════════════════════════════════════════════════════════════
 * ADMIN COMPONENTS
 * Used by admin_users / admin_user_form / admin_sessions
 * templates. Admin classes are prefixed `admin-` to avoid
 * collision with general motif components.
 * ════════════════════════════════════════════════════════════ */

.admin-shell {
    background: var(--admin-bg);
    min-height: 100vh;
}

.admin-header {
    background: var(--admin-header-bg);
    color: var(--admin-header-color);
    padding: var(--space-4) var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}
.admin-header h1 { font-size: var(--text-lg); font-weight: var(--font-semibold); }
.admin-header img { height: 32px; }

.header-nav { display: flex; gap: var(--space-4); align-items: center; }
.header-nav a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: var(--text-sm);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    transition: background var(--duration-fast);
}
.header-nav a:hover { background: rgba(255, 255, 255, 0.15); }
.header-nav a.active { background: rgba(255, 255, 255, 0.2); }

.user-info { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.user-info .avatar {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-semibold);
}

.admin-container { max-width: var(--container-xl); margin: 0 auto; padding: var(--space-6); }
.admin-container-md { max-width: var(--container-md); margin: 0 auto; padding: var(--space-6); }

/* Toolbar above tables (search + filters + actions). */
.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
    gap: var(--space-3);
}
.admin-search-filters { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.admin-search-box { display: flex; align-items: center; }
.admin-search-box input {
    padding: var(--space-2) var(--space-3);
    border: var(--border-1) solid var(--color-border);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    font-size: var(--text-sm);
    width: 200px;
}
.admin-search-box button {
    padding: var(--space-2) var(--space-3);
    background: var(--admin-accent);
    border: none;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    color: #fff;
    cursor: pointer;
}
.admin-filter-select {
    padding: var(--space-2) var(--space-3);
    border: var(--border-1) solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    background: var(--admin-card-bg);
}

.admin-actions { display: flex; gap: var(--space-2); }

.admin-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    border-top: var(--border-1) solid var(--color-border);
}
.admin-pagination a, .admin-pagination span {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: var(--text-sm);
    color: var(--color-fg);
}
.admin-pagination a:hover { background: var(--color-neutral-100); }
.admin-pagination .current { background: var(--admin-accent); color: #fff; }

/* Admin table extras (sessions). */
tr.current-session { background: var(--color-info-50); }
.session-id { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-fg-muted); }
.timestamp { font-size: var(--text-xs); color: var(--color-fg-muted); }

/* Admin form (admin_user_form). */
.form-card {
    background: var(--admin-card-bg);
    border-radius: var(--admin-card-radius);
    box-shadow: var(--admin-card-shadow);
    padding: var(--space-8);
}
.card-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--color-fg);
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: var(--border-1) solid var(--color-border);
}
.form-section { margin-bottom: var(--space-6); }
.form-section-title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--color-fg-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    margin-bottom: var(--space-4);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
