/* Built on the Currents design tokens: hairline borders, 12px card radius,
   headings at weight 500, numbers and keys in the mono face. */

/* Shell — sidebar left, content right, matching the other products. */

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    flex: none;
    width: 264px;
    padding: 20px 12px;
    background: var(--sidebar, var(--muted));
    border-right: 1px solid var(--border);
    overflow: hidden;
    transition: width 0.2s ease;
}

/* Collapsing. The class is on <html>, set before paint next to the theme, so a
   sidebar someone put away stays away across loads. */
.sidebar-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-toggle,
.sidebar-expand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 6px);
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
}

.sidebar-toggle { margin-top: 4px; }

.sidebar-toggle:hover,
.sidebar-expand:hover {
    background: var(--accent);
    color: var(--foreground);
}

.sidebar-toggle svg,
.sidebar-expand svg { width: 16px; height: 16px; }

.sidebar-expand {
    display: none;
    margin-right: auto;
}

html.sidebar-collapsed .sidebar {
    width: 0;
    padding-inline: 0;
    border-right: none;
    visibility: hidden;
}

html.sidebar-collapsed .sidebar-expand { display: inline-flex; }

@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
}

.sidebar-brand {
    display: block;
    padding: 4px 12px 24px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: var(--tracking-tight, -0.02em);
    color: var(--foreground);
}

.sidebar-nav { flex: 1; }

.sidebar-section + * { margin-top: 0; }
.sidebar-link + .sidebar-section { margin-top: 20px; }

.sidebar-section {
    margin: 0 0 6px;
    padding-top: 0;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    font-family: var(--font-text);
    font-size: 14px;
    font-weight: 500;
    color: var(--foreground);
    background: transparent;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-align: left;
}

.sidebar-link svg { width: 18px; height: 18px; flex: none; }

.sidebar-link:hover { background: var(--accent); color: var(--foreground); }

.sidebar-link.is-current {
    background: var(--card);
    color: var(--primary);
    box-shadow: var(--shadow-xs);
}

.sidebar-link.is-danger { color: var(--destructive); }
.sidebar-link.is-danger:hover {
    background: color-mix(in oklch, var(--destructive) 10%, transparent);
    color: var(--destructive);
}

.sidebar-foot { padding-top: 12px; }

.content {
    flex: 1;
    min-width: 0;
    padding: 20px 40px 64px;
}

.content-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 20px;
}

.content-user {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted-foreground);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--foreground);
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.theme-toggle:hover { background: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }

h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.lede {
    color: var(--muted-foreground);
    font-size: 14px;
    margin: 0 0 32px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

/* Forms */

.field {
    display: block;
    margin-bottom: 16px;
}

.field > span {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted-foreground);
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    font-family: var(--font-text);
    font-size: 14px;
    color: var(--foreground);
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius-lg);
}

.field input:focus {
    outline: 3px solid color-mix(in oklch, var(--ring) 50%, transparent);
    outline-offset: 0;
    border-color: var(--ring);
}

.field-error {
    color: var(--destructive);
    font-size: 12px;
    margin-top: 6px;
}

/* Keys */

.keys { width: 100%; border-collapse: collapse; font-size: 14px; }
.keys th {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted-foreground);
    padding: 0 12px 10px 0;
    border-bottom: 1px solid var(--border);
}
.keys td { padding: 14px 12px 14px 0; border-bottom: 1px solid var(--border); }
.keys tr:last-child td { border-bottom: none; }

.key-mask { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.chip {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--muted);
    color: var(--muted-foreground);
}

.chip-live { background: color-mix(in oklch, var(--rise) 15%, transparent); color: var(--rise); }
.chip-revoked { background: var(--muted); color: var(--muted-foreground); }

.key-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* The one showing of a new key */

.reveal {
    border: 1px solid var(--primary);
    background: color-mix(in oklch, var(--primary) 5%, transparent);
    border-radius: var(--radius-xl);
    padding: 20px;
    margin-bottom: 32px;
}

.reveal h2 { font-size: 16px; margin-bottom: 4px; }

.reveal p { font-size: 13px; color: var(--muted-foreground); margin: 0 0 14px; }

.reveal-key {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reveal-key code {
    flex: 1;
    padding: 10px 12px;
    font-size: 13px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    white-space: nowrap;
}

.empty {
    padding: 40px 0;
    text-align: center;
    color: var(--muted-foreground);
    font-size: 14px;
}

.messages { list-style: none; padding: 0; margin: 0 0 24px; }

.message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: var(--radius-lg);
    background: color-mix(in oklch, var(--primary) 12%, transparent);
    color: var(--foreground);
    margin-bottom: 8px;
}

/* --breakout is the design system's amber accent; a revoked key that still
   answers for a minute is exactly the kind of thing it is for. */
.message-warning {
    background: color-mix(in oklch, var(--breakout) 14%, transparent);
    border: 1px solid color-mix(in oklch, var(--breakout) 40%, transparent);
}

.message-warning::before {
    content: "";
    flex: none;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    background: var(--breakout);
    /* Lucide triangle-alert, masked so it takes the accent colour. */
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.7 18-8-14a2 2 0 0 0-3.4 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.7-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}

.message-error {
    background: color-mix(in oklch, var(--destructive) 12%, transparent);
    color: var(--destructive);
}

.form-actions { margin-top: 24px; }

.aside { font-size: 13px; color: var(--muted-foreground); margin-top: 20px; text-align: center; }

/* Auth pages — one card centred on the ground, in whichever theme the visitor
   is already in. Every colour here is a token, so the same markup carries both:
   the card, the ground and the lockup all swap together. */

.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    min-height: 100vh;
    padding: 40px 24px;
    background: var(--background);
}

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

.auth-brand { display: flex; align-items: center; margin-bottom: 20px; }

/* One lockup per ground: the white mark would vanish on a light card. */
.auth-brand .brand-on-dark { display: none; }
.dark .auth-brand .brand-on-dark { display: block; }
.dark .auth-brand .brand-on-light { display: none; }

/* allauth sizes nothing itself, so without these its h1 lands at the browser's
   2em and a card meant to be read in one glance becomes a wall. */

.auth-title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 500;
    letter-spacing: var(--tracking-tight);
}

.auth-heading {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 500;
}

.auth-sub,
.auth-text {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--muted-foreground);
}

.auth-text:last-of-type { margin-bottom: 24px; }

/* allauth puts its closing "contact us if you have trouble" line after the
   form, where it would otherwise sit right on top of the submit button. */
.auth-card form + .auth-text { margin: 20px 0 0; }

.auth-text a { color: var(--primary); }

.auth-rule { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.auth-card form,
.auth-form { display: flex; flex-direction: column; }

.auth-actions { display: flex; flex-direction: column; gap: 8px; }

.auth-panel { margin-bottom: 24px; }

.auth-providers { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.auth-providers a { width: 100%; }

.auth-error {
    margin: 0 0 16px;
    padding: 10px 12px;
    font-size: 13px;
    border-radius: var(--radius-lg);
    background: color-mix(in oklch, var(--destructive) 12%, transparent);
    color: var(--destructive);
}

/* A message here reports what already happened — it is not the page's subject,
   so it reads as a quiet footnote rather than a second filled banner. */

.auth-messages { list-style: none; padding: 0; margin: 20px 0 0; }

.auth-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted-foreground);
}

.auth-message::before {
    content: "";
    flex: none;
    width: 15px;
    height: 15px;
    margin-top: 2px;
    background: var(--rise);
    /* Lucide mail-check — the message on these pages is always about mail sent. */
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8'/%3E%3Cpath d='m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7'/%3E%3Cpath d='m16 19 2 2 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
}

.auth-message-error,
.auth-message-error::before { color: var(--destructive); background: var(--destructive); }
.auth-message-error { background: none; }

.auth-note {
    margin: 0 0 16px;
    padding: 10px 12px;
    font-size: 13px;
    border-radius: var(--radius-lg);
    background: color-mix(in oklch, var(--primary) 12%, transparent);
    color: var(--foreground);
}

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 16px 0 0;
    font-size: 13px;
}

.auth-links a { color: var(--primary); }
.auth-links a:hover { opacity: 0.8; }

/* Where someone goes next when the answer is not on this page. Present on every
   auth screen, so nobody is left on a dead end with only a back button. */

.auth-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    font-size: 12px;
}

.auth-foot a { color: var(--muted-foreground); }
.auth-foot a:hover { color: var(--primary); }

/* allauth's own pages render plain markup into the card, so the basics need to
   look right without a hand-written template for each one. */

.auth-card form p { margin: 0 0 16px; }
.auth-card .field > label > span,
.auth-card label { display: block; font-size: 12px; font-weight: 500; color: var(--muted-foreground); margin-bottom: 6px; }
.auth-card input[type="email"],
.auth-card input[type="text"],
.auth-card input[type="password"] {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    font-family: var(--font-text);
    font-size: 14px;
    color: var(--foreground);
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius-lg);
}
.auth-card [data-cbtn] { width: 100%; }
.auth-card a { color: var(--primary); }
.auth-card ul:not(.auth-messages):not(.auth-providers) { list-style: none; padding: 0; margin: 0 0 16px; font-size: 13px; }
.auth-card .errorlist { color: var(--destructive); }

.field-check { display: flex; align-items: center; gap: 8px; }
.field-check input { width: auto; height: auto; }
.field-check label { margin: 0; }

.field-help { display: block; margin-top: 6px; font-size: 12px; color: var(--muted-foreground); }

/* Legal documents. Long-form prose in a shell built for dashboards, so the
   measure is capped rather than run to the content width. */

.legal-doc {
    max-width: 48rem;
    font-size: 14px;
    line-height: 1.65;
}

/* The token reset renders every anchor as body text, which on a page whose whole
   job is to carry links left them invisible. */
.legal-doc a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.legal-doc a:hover { opacity: 0.8; }

.legal-doc > h2:first-of-type { margin-top: 0; }

.legal-doc h2 {
    margin: 32px 0 12px;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: var(--tracking-tight);
}

.legal-doc h3 {
    margin: 20px 0 8px;
    font-size: 14px;
    font-weight: 500;
}

.legal-doc p { margin: 0 0 12px; }

.legal-doc ul {
    margin: 0 0 12px;
    padding-left: 20px;
}

.legal-doc li { margin-bottom: 4px; }

.legal-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 16px;
    margin: 0 0 28px;
    padding: 14px 18px;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 13px;
}

.legal-meta dt {
    color: var(--muted-foreground);
    font-size: 12px;
}

.legal-meta dd { margin: 0; }

.legal-toc {
    margin: 0 0 28px;
    padding: 14px 18px 14px 34px;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 13px;
}

.legal-toc ol { margin: 0; padding: 0; }
.legal-toc li { margin-bottom: 2px; }

.legal-back {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
