/* plugwith.me — Auth + tenant-dashboard styles.
   Shared by /signup, /login, /app — kept intentionally separate from
   admin/style.css so the public auth flow has no dependency on the
   1.4k-line admin sheet. */

:root {
    --primary: #7c3aed;
    --highlight: #f43f5e;
    --accent: #06b6d4;
    --bg: #0a0a0f;
    --bg-card: #14141f;
    --bg-soft: #1a1a26;
    --bg-hover: #1f1f2c;
    --text: #f0f0f5;
    --text-muted: rgba(255, 255, 255, 0.62);
    --text-dim: rgba(255, 255, 255, 0.38);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.18);
    --danger: #ef4444;
    --success: #10b981;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); min-height: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    background:
        radial-gradient(900px 500px at 50% -10%, rgba(124, 58, 237, 0.18), transparent 60%),
        radial-gradient(700px 400px at 110% 110%, rgba(6, 182, 212, 0.12), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    min-height: 100vh;
    min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }

/* ─── Auth shell ─── */
.auth-shell {
    max-width: 440px;
    margin: 0 auto;
    padding: 40px 22px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    min-height: 100vh;
    min-height: 100dvh;
}
.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.01em;
}
.auth-brand-text {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.auth-card {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 32px 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.auth-card h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
}
.auth-sub {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}
.auth-field input {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}
.auth-field input:focus {
    outline: none;
    border-color: rgba(124, 58, 237, 0.5);
    background: var(--bg-hover);
}
.auth-field input::placeholder { color: var(--text-dim); }
.auth-submit {
    margin-top: 6px;
    padding: 13px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 6px 22px rgba(124, 58, 237, 0.35);
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.auth-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(124, 58, 237, 0.5);
}
.auth-submit:disabled { opacity: 0.65; cursor: wait; }
.auth-error {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    font-size: 13px;
}
.auth-success {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
    font-size: 13px;
}
.auth-hint {
    margin-top: 4px;
    text-align: center;
    font-size: 11.5px;
    color: var(--text-dim);
    line-height: 1.5;
}
.auth-foot {
    text-align: center;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-muted);
}
.auth-foot a { color: var(--primary); font-weight: 600; }
.auth-foot a:hover { text-decoration: underline; }
.auth-legal {
    margin-top: 12px;
    font-size: 11.5px;
    text-align: center;
    color: var(--text-dim);
    line-height: 1.5;
}
.auth-legal a { color: var(--text-muted); text-decoration: underline; }

.auth-btn-ghost {
    padding: 8px 14px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.auth-btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-hover); }

/* ─── App shell (tenant dashboard skeleton) ─── */
.app-shell {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 22px 60px;
    min-height: 100vh;
    min-height: 100dvh;
}
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}
.app-header-actions { display: inline-flex; align-items: center; gap: 10px; }
.app-tenant-chip {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 9999px;
}
.app-welcome h1 {
    font-size: clamp(24px, 4vw, 34px);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}
.app-welcome > p {
    color: var(--text-muted);
    margin-bottom: 28px;
    max-width: 560px;
}
.app-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 40px;
}
.app-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
}
.app-stat-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.app-stat-value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-bottom: 8px;
    word-break: break-word;
}
.app-stat-cap { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.app-stat-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
}
.app-stat-link:hover { text-decoration: underline; }
.app-stat-link-dim { color: var(--text-dim); }
.app-stat-link-dim:hover { text-decoration: none; }
.app-roadmap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
}
.app-roadmap h2 {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}
.app-roadmap ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
}
.app-roadmap li {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.55;
    padding-left: 18px;
    position: relative;
}
.app-roadmap li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 700;
}
.app-roadmap strong { color: var(--text); font-weight: 700; }

/* Inline banner used for Stripe-checkout round-trip status + checkout errors. */
.app-banner {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: 13.5px;
    line-height: 1.45;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.app-banner-success {
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.08);
    color: #6ee7b7;
}
.app-banner-info {
    border-color: rgba(124, 58, 237, 0.35);
    background: rgba(124, 58, 237, 0.08);
    color: var(--text);
}
.app-banner-error {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
    color: #fca5a5;
}
.app-banner-fade { opacity: 0; transform: translateY(-6px); }

/* Stat card with multiple actions stacked (free → "view pricing", paid →
   "manage subscription"). */
.app-plan-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.app-plan-portal {
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
}
.app-plan-portal:hover { text-decoration: underline; }
.app-plan-portal:disabled { opacity: 0.6; cursor: wait; }

/* ─── App-section base (Links + Models lists) ─── */
.app-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px 24px;
    margin-top: 22px;
}
.app-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}
.app-section-head h2 {
    font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 0;
}

.app-btn-primary, .app-btn-secondary, .app-btn-ghost, .app-btn-danger, .app-btn-ghost-sm {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 14px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
}
.app-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}
.app-btn-primary:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.app-btn-primary:disabled { opacity: 0.65; cursor: wait; }
.app-btn-secondary {
    background: var(--bg-soft);
    border-color: var(--border);
    color: var(--text);
}
.app-btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.app-btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}
.app-btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-soft); }
.app-btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--danger);
}
.app-btn-danger:hover { background: rgba(239, 68, 68, 0.2); }
.app-btn-ghost-sm {
    padding: 6px 10px;
    font-size: 12px;
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}
.app-btn-ghost-sm:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-soft); }

.app-empty {
    padding: 24px 12px;
    color: var(--text-muted);
    text-align: center;
    font-size: 14px;
}

/* ─── Link cards ─── */
.app-link-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.app-link-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.15s, background 0.15s;
}
.app-link-card:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.app-link-card-main { flex: 1; min-width: 0; }
.app-link-card-row {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap; margin-bottom: 4px;
}
.app-link-card-title {
    font-size: 14px; font-weight: 700; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px;
}
.app-link-card-meta {
    display: flex; align-items: center; gap: 12px;
    font-size: 12px; color: var(--text-muted);
    flex-wrap: wrap;
}
.app-link-card-url {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-muted);
    text-decoration: none;
}
.app-link-card-url:hover { color: var(--primary); text-decoration: underline; }
.app-link-card-dest {
    color: var(--text-dim);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px;
}
.app-link-card-actions {
    display: inline-flex; gap: 6px; flex-shrink: 0;
}
.app-status-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
}
.app-status-live { background: var(--success); box-shadow: 0 0 6px rgba(16, 185, 129, 0.55); }
.app-status-paused { background: var(--text-dim); }
.app-type-chip, .app-meta-chip {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px; font-weight: 600;
    border: 1px solid var(--border);
}
.app-type-chip { color: var(--text-muted); background: var(--bg-card); }
.app-type-direct { border-color: rgba(124, 58, 237, 0.4); color: var(--primary); }
.app-type-linktree { border-color: rgba(244, 63, 94, 0.4); color: var(--highlight, #f43f5e); }
.app-meta-chip { color: var(--text-muted); background: var(--bg-soft); }

/* ─── Model cards ─── */
.app-model-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}
.app-model-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.app-model-avatar {
    width: 40px; height: 40px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-soft);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.app-model-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-model-initial { font-size: 16px; font-weight: 700; color: var(--text-muted); }
.app-model-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.app-model-name { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-model-meta { font-size: 11.5px; color: var(--text-dim); }

/* ─── Modal ─── */
.app-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    overscroll-behavior: contain;
    overflow-y: auto;
}
.app-modal-overlay[hidden] { display: none; }
.app-modal {
    width: 100%;
    max-width: 560px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    display: flex; flex-direction: column;
    max-height: calc(100dvh - 40px);
}
.app-modal-small { max-width: 420px; }
.app-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.app-modal-head h3 { font-size: 16px; font-weight: 700; margin: 0; }
.app-modal-close {
    background: none; border: none;
    color: var(--text-muted); font-size: 22px; line-height: 1;
    cursor: pointer; padding: 4px 10px;
    border-radius: 6px;
    font-family: inherit;
}
.app-modal-close:hover { color: var(--text); background: var(--bg-soft); }
.app-modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.app-modal-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.app-modal-foot .app-btn-danger { margin-right: auto; }

.app-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.app-field > span:first-child, .app-field-label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.02em; }
.app-field input[type="text"], .app-field input[type="url"], .app-field select {
    padding: 9px 11px;
    border-radius: 8px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s, background 0.15s;
}
.app-field input:focus, .app-field select:focus {
    outline: none; border-color: rgba(124, 58, 237, 0.55); background: var(--bg-hover);
}
.app-field input[disabled] { opacity: 0.6; cursor: not-allowed; }

.app-field-row { display: flex; gap: 12px; margin-bottom: 14px; }
.app-field-row .app-field { flex: 1; margin-bottom: 0; }
@media (max-width: 540px) { .app-field-row { flex-direction: column; } }

.app-slug-row {
    display: flex; align-items: stretch;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.app-slug-row:focus-within { border-color: rgba(124, 58, 237, 0.55); }
.app-slug-prefix {
    padding: 9px 11px;
    background: var(--bg);
    color: var(--text-dim);
    font-size: 12.5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    border-right: 1px solid var(--border);
}
.app-slug-row input {
    flex: 1; min-width: 0;
    background: transparent; border: none;
    padding: 9px 11px;
    font-size: 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text);
}
.app-slug-row input:focus { outline: none; }

.app-toggle-row {
    display: inline-flex; gap: 4px;
    background: var(--bg-soft);
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 9px;
}
.app-toggle {
    background: transparent;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
}
.app-toggle.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 0 0 1px var(--border-strong);
}

.app-button-row {
    display: flex; gap: 6px;
    margin-bottom: 6px;
}
.app-button-row input { flex: 1; min-width: 0; }
.app-button-row .app-btn-row-remove {
    padding: 0 10px;
    font-size: 16px;
    line-height: 1;
    color: var(--text-muted);
}

.app-advanced {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
}
.app-advanced summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    list-style: none;
}
.app-advanced summary::before {
    content: '▸ ';
    transition: transform 0.15s;
    display: inline-block;
}
.app-advanced[open] summary::before { content: '▾ '; }
.app-checkbox { flex-direction: row; align-items: center; gap: 10px; }
.app-checkbox input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.app-checkbox > span { font-size: 13.5px; color: var(--text); font-weight: 500; letter-spacing: 0; text-transform: none; }

.app-modal-error {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 13px;
    margin-top: 8px;
}

.app-linktree-buttons { margin-bottom: 14px; }

/* Mobile tightening */
@media (max-width: 600px) {
    .app-section { padding: 18px 14px; }
    .app-link-card { flex-wrap: wrap; }
    .app-link-card-actions { width: 100%; justify-content: flex-end; padding-top: 6px; }
    .app-link-card-title { max-width: 100%; }
    .app-modal { max-height: calc(100dvh - 16px); }
    .app-modal-body { padding: 14px 16px; }
    .app-modal-head, .app-modal-foot { padding: 12px 16px; }
}

@media (max-width: 540px) {
    .app-header { flex-direction: column; align-items: stretch; }
    .app-header-actions { justify-content: space-between; }
}
