/* Manody stylesheet, part 02 — Dashboard: overview, statistics, links, appearance, page themes, error page and dashboard forms.
   Loaded in order by core/templates/core/includes/stylesheets.html. */

/* ---------- Dashboard ---------- */
.page-dashboard {
    background: var(--bg-soft);
}

.page-dashboard .site-header {
    background: color-mix(in srgb, var(--bg-soft) 80%, transparent);
}

.dashboard {
    padding-block: 48px 80px;
}

.dash-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 32px;
}

.dash-header .eyebrow {
    margin-bottom: 12px;
}

.dash-header h1 {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.share {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    max-width: 100%;
}

.share-url {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.share-url strong {
    color: var(--text);
    font-weight: 600;
}

.btn-sm {
    height: 34px;
    padding: 0 14px;
    font-size: 0.85rem;
}

.btn.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
    gap: 24px;
}

.dash-main {
    display: grid;
    gap: 24px;
}

.card {
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

/* Cards stacked directly in a dashboard screen: the same breathing room as the grids (24px). */
.dashboard > .card + .card,
.dashboard > .card + form,
.dashboard > form + .card { margin-top: 24px; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.card-note {
    margin-top: 16px;
    font-size: 0.85rem;
}

.small {
    font-size: 0.8rem;
}

/* Statistics */
.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    margin: 0;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.stat {
    padding: 18px 20px;
    background: var(--surface);
}

.stat dt {
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat dd {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

/* Links */
.link-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.link-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.link-info {
    display: grid;
    min-width: 0;
}

.link-title {
    font-weight: 500;
}

.link-url {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
}

.empty {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 32px 16px;
    text-align: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 4px;
    border-radius: 50%;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

.empty-icon svg {
    width: 20px;
    height: 20px;
}

.empty h3 {
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.empty p {
    max-width: 26rem;
    font-size: 0.9rem;
}

.empty .btn {
    margin-top: 12px;
}

/* Appearance */
.themes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.theme {
    display: grid;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-muted);
}

.theme.is-active {
    color: var(--text);
}

.theme-swatch {
    display: block;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.theme.is-active .theme-swatch {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-light  { background: #ffffff; }
.theme-dark   { background: #18181b; }
.theme-sand   { background: #efe6d8; }
.theme-forest { background: #1f3a2e; }

/* Preview */
.dash-preview {
    position: sticky;
    top: calc(var(--header-h) + 24px);
}

.phone-flat {
    max-width: none;
    transform: none;
    box-shadow: var(--shadow);
}

.profile-links.is-placeholder li {
    background: var(--bg);
    border-style: dashed;
}

.avatar {
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Public page themes (public page and previews). Each theme sets all
   its colors, so it looks the same whatever the dashboard mode. */
.page-theme-light {
    --bg: #ffffff; --bg-soft: #fafafa; --surface: #ffffff; --border: #e4e4e7;
    --text: #18181b; --text-muted: #71717a; --accent: #18181b; --accent-contrast: #ffffff;
}

.page-theme-dark {
    --bg: #09090b; --bg-soft: #18181b; --surface: #27272a; --border: #3f3f46;
    --text: #fafafa; --text-muted: #a1a1aa; --accent: #fafafa; --accent-contrast: #09090b;
}

.page-theme-sand {
    --bg: #f7f1e8; --bg-soft: #efe6d8; --surface: #fbf8f3; --border: #dccfbb;
    --text: #3b2f22; --text-muted: #7c6a55; --accent: #3b2f22; --accent-contrast: #fbf8f3;
}

.page-theme-forest {
    --bg: #16291f; --bg-soft: #1f3a2e; --surface: #29493a; --border: #3a5f4d;
    --text: #eef5f0; --text-muted: #a9c3b4; --accent: #d8ead0; --accent-contrast: #16291f;
}

[class*="page-theme-"] {
    color: var(--text);
}

.buttons-pill .profile-links li {
    border-radius: 999px;
}

.buttons-square .profile-links li {
    border-radius: 4px;
}

/* Dashboard links */
.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-contrast);
    font-size: 0.7rem;
    font-weight: 500;
    vertical-align: 2px;
}

.badge-muted {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.link-row.is-hidden .link-title,
.link-row.is-hidden .link-url {
    opacity: 0.55;
}

.link-clicks {
    flex-shrink: 0;
}

/* ---------- Error page ---------- */
.error-page {
    display: grid;
    justify-items: center;
    max-width: 36rem;
    margin-inline: auto;
    padding: 96px 24px 112px;
    text-align: center;
}

.error-code {
    margin-bottom: 16px;
    font-size: clamp(5rem, 18vw, 8.5rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.06em;
    background: linear-gradient(180deg, var(--text) 30%, var(--border-strong));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    user-select: none;
}

.error-page h1 {
    margin-bottom: 12px;
    font-size: clamp(1.6rem, 4vw, 2.1rem);
}

.error-path {
    padding: 2px 8px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    color: var(--text);
    word-break: break-all;
}

.error-hint {
    margin-top: 12px;
}

.error-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 32px;
}

/* ---------- Dashboard forms ---------- */
.narrow {
    max-width: 640px;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
}

.back-link:hover {
    color: var(--text);
}

.form-header {
    margin-bottom: 24px;
}

.form-header h1 {
    margin-bottom: 6px;
    font-size: clamp(1.5rem, 3.5vw, 1.9rem);
}

.card-title {
    margin-bottom: 18px;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.form-actions-end {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    opacity: 0.88;
}

.btn-danger-ghost {
    background: transparent;
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.btn-danger-ghost:hover {
    background: var(--danger-soft);
}

.delete-hint {
    margin-block: 16px 8px;
}

.delete-hint a {
    color: var(--text);
}

/* Checkboxes */
.check label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}

.check label > span {
    display: grid;
    gap: 2px;
}

.check-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.check input,
.check-inline input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    flex-shrink: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 400 !important;
    cursor: pointer;
}

.check-inline input {
    margin: 0;
}

.field-label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Profile picture */
.avatar-field {
    display: flex;
    align-items: center;
    gap: 20px;
}

.avatar-lg {
    width: 72px;
    height: 72px;
    margin: 0;
    flex-shrink: 0;
}

.avatar-actions {
    display: grid;
    justify-items: start;
    gap: 8px;
}

.avatar-actions .btn {
    cursor: pointer;
}

.avatar-actions input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.avatar-actions:has(input[type="file"]:focus-visible) .btn {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Visual choices (theme, button style) */
.choice-grid {
    display: grid;
    gap: 12px;
}

.choice-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.choice-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.choice {
    position: relative;
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.choice:hover {
    border-color: var(--border-strong);
}

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
    color: var(--text);
}

.choice:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.button-sample {
    display: block;
    height: 28px;
    margin: 8px 6px;
    background: var(--bg-soft);
    border: 1px solid var(--border-strong);
}

.button-sample-rounded { border-radius: 8px; }
.button-sample-pill    { border-radius: 999px; }
.button-sample-square  { border-radius: 2px; }

/* Link rows: reorder, edit, delete */
.link-order {
    display: grid;
    flex-shrink: 0;
}

.link-order form {
    margin: 0;
}

.link-order .icon-btn {
    width: 26px;
    height: 20px;
}

.link-row .link-info {
    flex: 1;
}

.link-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn:hover:not(:disabled) {
    background: var(--bg-soft);
    color: var(--text);
}

.icon-btn-danger:hover {
    color: var(--danger) !important;
}

.icon-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

/* Confirmation messages */
.toasts {
    position: fixed;
    bottom: 24px;
    left: 50%;
    z-index: 20;
    display: grid;
    gap: 8px;
    width: max-content;
    max-width: calc(100% - 32px);
    transform: translateX(-50%);
}

.toast {
    padding: 12px 18px;
    background: var(--accent);
    color: var(--accent-contrast);
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    animation: toast 4.5s ease forwards;
}

.toast-error {
    background: var(--danger);
    color: #ffffff;
}

@keyframes toast {
    0%   { opacity: 0; transform: translateY(8px); }
    6%   { opacity: 1; transform: none; }
    88%  { opacity: 1; transform: none; }
    100% { opacity: 0; transform: translateY(8px); visibility: hidden; }
}
