﻿/*
 * NFC Link Manager: components layered over the compiled Tailwind utilities
 * (assets/tailwind-manager.css). Each class below replaces a long utility string
 * that used to be repeated across the page.
 */

body {
    background: #f8fafc;
    color: #0f172a;
    -webkit-text-size-adjust: 100%;
}

.panel {
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.label {
    display: block;
    margin-bottom: 0.25rem;
    color: #334155;
    font-size: 0.75rem;
    font-weight: 600;
}

.field {
    display: block;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: #fff;
    color: #0f172a;
    font-size: 0.875rem;
}

.field:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -1px;
}

.field[readonly] {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: wait;
}

.btn-secondary {
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
}

.btn-secondary:hover {
    background: #f8fafc;
    color: #2563eb;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-height: 2.25rem;
    padding: 0.375rem 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    border-radius: 0.5rem;
    color: #94a3b8;
    transition: background-color 0.15s, color 0.15s;
}

.icon-action:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Active/suspended switch: a native checkbox restyled as a toggle */
.switch {
    position: relative;
    width: 2.5rem;
    height: 1.5rem;
    flex-shrink: 0;
    appearance: none;
    border-radius: 9999px;
    background: #cbd5e1;
    cursor: pointer;
    transition: background-color 0.2s;
}

.switch::after {
    content: "";
    position: absolute;
    top: 0.1875rem;
    left: 0.1875rem;
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.switch:checked {
    background: #10b981;
}

.switch:checked::after {
    transform: translateX(1rem);
}

.safe-bottom {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

#toastContainer {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    z-index: 150;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

@media (min-width: 640px) {
    #toastContainer {
        right: 1.25rem;
        bottom: 1.25rem;
        left: auto;
        width: 22rem;
    }
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: #1e293b;
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateY(0.5rem);
    transition: opacity 0.25s, transform 0.25s;
}

.toast.show {
    opacity: 1;
    transform: none;
}

/* Phones: 16px inputs stop iOS from zooming on focus */
@media (max-width: 767.98px) {
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast,
    .switch,
    .switch::after {
        transition: none !important;
    }
}

/* Left padding for inputs with a leading prefix or icon. These come after .field so they win. */
.field.has-icon {
    padding-left: 2.25rem;
}

.field.has-prefix {
    padding-left: 5.5rem;
}

@media (min-width: 640px) {
    .field.has-prefix {
        padding-left: 6.25rem;
    }
}

/* ---------- Hub editor ---------- */

.hub-section {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #fff;
}

.hub-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    color: #0f172a;
    font-size: 0.9375rem;
    font-weight: 600;
}

.hub-title i {
    color: #3b82f6;
    font-size: 1.125rem;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
}

.choice,
.tile,
.toggle-chip {
    position: relative;
    cursor: pointer;
}

.choice input,
.tile input,
.toggle-chip input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-height: 4.5rem;
    padding: 0.5rem 0.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #fff;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

.choice i {
    color: #64748b;
    font-size: 1.25rem;
}

.choice:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    box-shadow: 0 0 0 1px #2563eb;
}

.choice:has(input:checked) i {
    color: #2563eb;
}

.choice:has(input:focus-visible),
.tile:has(input:focus-visible),
.toggle-chip:has(input:focus-visible) {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .tile-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 0.375rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #fff;
}

.tile-swatch {
    display: block;
    height: 3.5rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 0.5rem;
}

.tile-label {
    color: #334155;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

.tile:has(input:checked) {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px #bfdbfe;
}

.toggle-chip {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.5rem 0.875rem;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    background: #fff;
    color: #475569;
    font-size: 0.8125rem;
    font-weight: 500;
}

.toggle-chip:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

.color-input {
    display: block;
    width: 100%;
    height: 2.75rem;
    padding: 0.25rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background: #fff;
    cursor: pointer;
}

.avatar-picker,
.icon-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4.5rem;
    height: 4.5rem;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px dashed #94a3b8;
    border-radius: 0.875rem;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
}

.avatar-picker:hover,
.icon-picker:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.link-card {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #fff;
}

/* Icon popup: opens directly under the icon picker */
.icon-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    z-index: 30;
    width: min(20rem, calc(100vw - 3rem));
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 12px 30px -8px rgba(15, 23, 42, 0.25);
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.375rem;
    max-height: 14rem;
    overflow-y: auto;
}

.icon-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-height: 3.25rem;
    padding: 0.375rem 0.25rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: transparent;
    color: #334155;
    font-size: 0.6875rem;
    cursor: pointer;
}

.icon-option i {
    font-size: 1.125rem;
}

.icon-option:hover {
    background: #f1f5f9;
}

.icon-option.is-selected {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
}

.icon-option span {
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 2.75rem;
    cursor: pointer;
}

@media (max-width: 767.98px) {
    .choice-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .field {
        min-height: 2.75rem;
    }

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

/* ---------- Hub editor: two-line button cards and colour fields ---------- */

.link-card {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.link-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.link-line > .field {
    min-width: 0;
}

.toggle-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.toggle-group .toggle-chip {
    min-height: 2.25rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.icon-picker {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.625rem;
}

.icon-picker i {
    font-size: 1.125rem;
}

.icon-menu-title {
    margin-bottom: 0.5rem;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
}

.hub-title-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    text-align: center;
}

.hub-title-row .hub-title {
    margin-bottom: 0;
    justify-content: center;
}

@media (min-width: 640px) {
    .hub-title-row {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }

    .hub-title-row .hub-title {
        justify-content: flex-start;
    }
}

/* Colour field: picker swatch, hex box and quick colours on one row */
.color-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.color-swatch {
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    padding: 0.2rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.625rem;
    background: #fff;
    cursor: pointer;
}

.color-swatch::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-swatch::-webkit-color-swatch {
    border: 0;
    border-radius: 0.375rem;
}

.color-hex {
    width: 7.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    text-transform: lowercase;
}

.color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.color-dot {
    width: 1.75rem;
    height: 1.75rem;
    border: 2px solid #fff;
    border-radius: 9999px;
    box-shadow: 0 0 0 1px #cbd5e1;
    cursor: pointer;
}

.color-dot:hover {
    transform: scale(1.1);
}

/* ---------- Refined look: softer surfaces, clearer hierarchy ---------- */

body {
    min-height: 100vh;
    background:
        radial-gradient(1100px 520px at 0% -10%, #dbeafe 0%, transparent 60%),
        radial-gradient(900px 480px at 110% 0%, #e0e7ff 0%, transparent 55%),
        #f1f5f9;
}

.panel {
    border-color: #e2e8f0;
    border-radius: 1.25rem;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px -16px rgba(15, 23, 42, 0.18);
}

.label {
    margin-bottom: 0.375rem;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.field {
    border-color: #d5deea;
    border-radius: 0.75rem;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field:hover {
    border-color: #94a3b8;
}

.field:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.btn-primary {
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    box-shadow: 0 8px 18px -8px rgba(37, 99, 235, 0.55);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #4338ca);
    box-shadow: 0 10px 22px -8px rgba(37, 99, 235, 0.6);
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.icon-action:focus-visible,
.chip:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.btn-secondary {
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.btn-secondary:hover {
    border-color: #bfdbfe;
    box-shadow: 0 4px 10px -6px rgba(37, 99, 235, 0.4);
}

.chip {
    border-radius: 9999px;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.chip:active {
    transform: scale(0.97);
}

.icon-action {
    border-radius: 0.625rem;
}

.hub-section {
    border-color: #e2e8f0;
    border-radius: 1.125rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.hub-title {
    font-size: 0.9375rem;
    letter-spacing: -0.005em;
}

.link-card {
    border-color: #e2e8f0;
    border-radius: 1.125rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.link-card:hover {
    border-color: #bfdbfe;
    box-shadow: 0 10px 22px -14px rgba(37, 99, 235, 0.45);
}

.toggle-chip {
    border-radius: 9999px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.choice,
.tile {
    border-radius: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.choice:hover,
.tile:hover {
    border-color: #bfdbfe;
}

.tile-swatch {
    border-radius: 0.75rem;
}

.icon-picker {
    border-radius: 0.75rem;
}

.modal {
    backdrop-filter: blur(4px);
}

/* Login card and session check */
#loginView > div {
    border-radius: 1.5rem;
    box-shadow: 0 30px 60px -24px rgba(15, 23, 42, 0.45);
}

.boot-spinner {
    width: 2.25rem;
    height: 2.25rem;
    border: 3px solid #cbd5e1;
    border-top-color: #2563eb;
    border-radius: 9999px;
    animation: boot-spin 0.8s linear infinite;
}

@keyframes boot-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .boot-spinner {
        animation-duration: 2.4s;
    }
}

.icon-upload {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    border: 1px solid #cbd5e1;
    border-radius: 0.625rem;
    background: #fff;
    color: #2563eb;
    font-size: 1.125rem;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.icon-upload:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

/* Button rows on phones: icons and move/delete on the first line, then the label, then the link */
@media (max-width: 639px) {
    .link-line > .link-icons { order: 1; }
    .link-line > .link-actions { order: 2; margin-left: auto; }
    .link-line > .link-label { order: 3; flex: 1 1 100%; }
    .link-line > .link-url { flex: 1 1 100%; }
}

/* Header buttons: a short "Reviews" label, no wrapping, and the three buttons share the phone width */
.short-label { display: none; }
@media (max-width: 639px) {
    .header-actions { flex-wrap: nowrap; gap: 0.5rem; width: 100%; }
    .header-actions .btn-secondary { flex: 1 1 0; min-width: 0; min-height: 2.75rem; padding: 0.5rem 0.5rem; font-size: 0.875rem; gap: 0.375rem; white-space: nowrap; }
    .header-actions .long-label { display: none; }
    .header-actions .short-label { display: inline; }
}

/* Profile picture preview: same size and shape as the upload button beside it */
.pfp-preview {
    width: 4.5rem;
    height: 4.5rem;
    flex-shrink: 0;
    object-fit: cover;
    border: 1px solid #e2e8f0;
    border-radius: 0.875rem;
    background: #f8fafc;
}

/* Header: on phones the fourth button sits on its own row under the first three */
@media (max-width: 767px) {
    .header-actions { flex-wrap: wrap; }
    /* First three fill one row; the PDF generator and Payments share the row under them */
    .header-actions > :nth-child(-n+3) { flex: 1 1 calc(33.33% - 0.34rem); min-width: 0; }
    .header-actions > :nth-child(4), .header-actions > :nth-child(5) { flex: 1 1 calc(50% - 0.25rem); min-width: 0; }
}
