/* ============================================================
   COMPONENTS — reusable UI elements
   Loaded on every page via _Layout.cshtml
   ============================================================ */

/* ── Nav user dropdown ───────────────────────────────────────────────────────
   Rich user dropdown: profile card at top, grouped links, sign-out footer. */
.nav-user-dropdown {
    min-width: 220px;
}
.nav-user-card {
    pointer-events: none;  /* card is display-only, not a click target */
}
.nav-user-dropdown .dropdown-item {
    font-size: .9rem;
}

/* ── User avatars ────────────────────────────────────────────────────────────
   Used in the nav dropdown, entity cards, bulletin posts, message bubbles,
   and the public profile page. The endpoint GET /Account/Avatar/{userId}
   always returns something (JPEG or SVG initials), so broken-image states
   are unreachable under normal operation. */
.user-avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}
.user-avatar--sm { width: 32px;  height: 32px;  }   /* nav toggle, admin list  */
.user-avatar--md { width: 40px;  height: 40px;  }   /* bulletin posts, messages */
.user-avatar--lg { width: 64px;  height: 64px;  }   /* entity cards, People     */
.user-avatar--xl { width: 96px;  height: 96px;  }   /* own profile page         */

/* Presence dot — small circle overlaid on the bottom-right of a user avatar.
   Colour class applied via Razor: text-success (<5 min), text-warning (<1 h). */
.presence-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
    border: 2px solid var(--color-bg);
}

/* Drop zone dashed border used in _AvatarCropModal */
.border-dashed { border-style: dashed !important; }

/* ── Auth pages (Login, LoginWith2fa, Setup2fa) ─────────────────────────────
   Centered card layout used by all account flows. */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 3rem 1rem 2rem;
}
.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2.25rem 2.5rem;
    width: 100%;
    max-width: 420px;
}
.auth-logo {
    display: block;
    height: 36px;
    width: auto;
    margin: 0 auto 1.5rem;
}
.auth-heading { font-size: 1.35rem; font-weight: 700; margin-bottom: .15rem; text-align: center; }
.auth-sub     { color: var(--color-muted); font-size: .9rem; text-align: center; margin-bottom: 1.5rem; }

/* Password show/hide toggle */
.auth-pw-wrap { position: relative; }
.auth-pw-wrap .form-control { padding-right: 2.8rem; }
.auth-pw-toggle {
    position: absolute;
    top: 50%;
    right: .65rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    padding: .2rem;
    line-height: 1;
    font-size: 1rem;
}
.auth-pw-toggle:hover { color: var(--color-text); }

/* Shake animation on failed login */
@keyframes auth-shake {
    0%  { transform: translateX(0); }
    15% { transform: translateX(-8px); }
    30% { transform: translateX(8px); }
    45% { transform: translateX(-6px); }
    60% { transform: translateX(6px); }
    75% { transform: translateX(-3px); }
    90% { transform: translateX(3px); }
    100%{ transform: translateX(0); }
}
.auth-card--shake { animation: auth-shake .45s ease-in-out; }

/* 6-digit TOTP input boxes */
.totp-boxes {
    display: flex;
    gap: .5rem;
    justify-content: center;
    margin: 1rem 0;
}
.totp-boxes input {
    width: 2.75rem;
    height: 3.25rem;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color .15s, box-shadow .15s;
}
.totp-boxes input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.2);
}

/* Password strength bar */
.pw-strength { margin-top: .4rem; }
.pw-strength-bar {
    display: flex;
    gap: 3px;
    height: 4px;
    margin-bottom: .25rem;
}
.pw-strength-bar span {
    flex: 1;
    border-radius: 2px;
    background: var(--color-border);
    transition: background .25s;
}
.pw-strength-bar span.active-1 { background: #dc2626; }
.pw-strength-bar span.active-2 { background: #f97316; }
.pw-strength-bar span.active-3 { background: #eab308; }
.pw-strength-bar span.active-4 { background: #16a34a; }
.pw-strength-label { font-size: .78rem; color: var(--color-muted); }

/* Setup 2FA onboarding steps */
.setup-2fa-steps {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
}
.setup-2fa-steps li {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    margin-bottom: 1.2rem;
}
.setup-2fa-steps li::before {
    counter-increment: step;
    content: counter(step);
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: .1rem;
}
.setup-2fa-steps li p { margin: 0; font-size: .9rem; }
.setup-2fa-steps li .step-detail { font-size: .8rem; color: var(--color-muted); margin-top: .2rem; }

/* Recovery codes display */
.recovery-codes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem .75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    margin: 1rem 0;
}
.recovery-codes-grid code {
    font-family: var(--font-mono);
    font-size: .9rem;
    letter-spacing: .05em;
}

/* ── Form section dividers ──────────────────────────────────────────────────
   Used on full-page forms to separate logical groups without card wrappers.
   Usage: <div class="form-section-label">Section Name</div>
          <hr class="form-section-rule" />
   See also: .inv-section-label / .inv-section-rule in inventory.css (aliases). */
.form-section-label {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--color-muted);
    margin-bottom: .35rem;
}
.form-section-rule {
    border: none;
    border-top: 1px solid var(--color-border);
    margin-top: 0;
    margin-bottom: 1rem;
}

/* ── Textarea height modifiers ──────────────────────────────────────────────
   Apply to a .form-floating > textarea or a plain textarea. */
.form-textarea-sm { height: 80px;  }
.form-textarea-md { height: 120px; }
.form-textarea-lg { height: 180px; }

/* --- Stat Cards (dashboard summary blocks) --- */
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}
.stat-card .stat-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); min-height: 2.5em; display: block; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; margin: .25rem 0 0; }
.stat-card .stat-sub   { font-size: .8rem; color: var(--color-muted); margin-top: .15rem; }

/* Tile computed under the page's active filters (or a pinned facet filter) — accent edge so a
   narrowed number is never mistaken for the all-up figure. */
.stat-card--filtered { border-left: 3px solid var(--color-primary); }

/* --- Insight tile pin / preview --- */
.stat-card { position: relative; }
.tile-pin,
.tile-preview {
    position: absolute;
    border: 0;
    background: transparent;
    color: var(--color-muted);
    font-size: .85rem;
    line-height: 1;
    padding: .15rem .25rem;
    border-radius: .25rem;
    opacity: 0;
    transition: opacity .15s ease;
    cursor: pointer;
}
.tile-pin    { top: .35rem; right: .4rem; }
.tile-preview { top: .35rem; left: .4rem; }
.stat-card:hover .tile-pin,
.stat-card:hover .tile-preview,
.tile-pin:focus-visible,
.tile-preview:focus-visible { opacity: 1; }
.tile-pin:hover    { color: var(--color-primary); background: rgba(13,110,253,.08); }
.tile-preview:hover { color: var(--color-success); background: rgba(25,135,84,.08); }
.tile-pin--done, .stat-card:hover .tile-pin--done { color: var(--color-primary); opacity: 1; }
@media (hover: none) { .tile-pin, .tile-preview { opacity: .5; } }

/* Transient confirmation after a pin saves. */
.pin-toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translate(-50%, 1rem);
    background: #212529;
    color: #fff;
    padding: .55rem 1rem;
    border-radius: .4rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    font-size: .85rem;
    z-index: 1080;
    opacity: 0;
    transition: opacity .25s ease, transform .25s ease;
    max-width: min(92vw, 480px);
}
.pin-toast.show { opacity: 1; transform: translate(-50%, 0); }
.pin-toast a { color: #8bb9fe; }

/* Gear-menu "add existing insight" picker panel (hidden until + Add opens it). */
.mc-add-picker { max-width: 480px; margin: 0.25rem 0 1rem; }

/* --- Data Tables --- */
.data-table { width: 100%; border-collapse: collapse; background: var(--color-surface); }
.data-table th {
    text-align: left;
    padding: .6rem .85rem;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
    background: var(--color-bg);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}
.data-table td {
    padding: .65rem .85rem;
    border-bottom: 1px solid var(--color-border);
    font-size: .9rem;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--color-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

/* --- Detail page info card (key/value DL layout) --- */
.item-detail-list { margin: 0; }
.detail-row { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px solid var(--color-border); }
.detail-row:last-child { border-bottom: none; }
.detail-row dt { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-muted); font-weight: 500; }
.detail-row dd { margin: 0; font-size: .9rem; font-weight: 500; text-align: right; }

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: .2em .55em;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 99px;
    line-height: 1;
}
.badge-unlisted { background: var(--badge-unlisted-bg);  color: var(--badge-unlisted-text);  }
.badge-listed   { background: var(--badge-listed-bg);    color: var(--badge-listed-text);    }
.badge-sold     { background: var(--badge-sold-bg);      color: var(--badge-sold-text);      }
.badge-ebay     { background: var(--badge-ebay-bg);      color: var(--badge-ebay-text);      }
.badge-resale   { background: var(--badge-resale-bg);    color: var(--badge-resale-text);    }

/* --- Buttons (extend Bootstrap) --- */
.btn-sm { font-size: .8rem; padding: .3rem .7rem; }
.btn-icon { padding: .2rem .4rem; line-height: 1; font-size: .8rem; }

/* --- Row quick-actions (Pin / Post / Remind) — fade in on row hover --- */
.row-quick-actions {
    display: inline-flex;
    gap: 1px;
    opacity: 0;
    transition: opacity .12s;
    pointer-events: none;
}
.data-table tbody tr:hover .row-quick-actions {
    opacity: 1;
    pointer-events: auto;
}
.btn-quick-action {
    padding: .15rem .28rem;
    font-size: .8rem;
    line-height: 1;
    border: none;
    background: transparent;
    color: var(--color-muted);
    border-radius: .2rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background .1s, color .1s;
}
.btn-quick-action:hover { background: var(--color-surface-alt); color: var(--color-text); }

/* --- Filter/Search Bar --- */
.filter-bar {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.filter-bar .form-control,
.filter-bar .form-select { max-width: 200px; font-size: .875rem; }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-muted);
}
.empty-state svg, .empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }

/* --- Summary bar (stat cards in a flex row, used on Sales / Reports / BulkResales) --- */
.report-summary-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

/* --- Profit coloring (used on Orders and Reports) --- */
.profit-positive { color: var(--color-profit-pos); font-weight: 600; }
.profit-negative { color: var(--color-profit-neg); font-weight: 600; }

/* --- Year-over-year delta badges (dashboard YoY row) --- */
.yoy-delta        { font-size: .75rem; font-weight: 600; }
.yoy-delta-up     { color: var(--color-profit-pos); }
.yoy-delta-down   { color: var(--color-profit-neg); }

/* --- Auth card (login / 2fa pages) --- */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}
.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
}
.auth-title    { font-size: 1.4rem; font-weight: 700; text-align: center; margin-bottom: .25rem; }
.auth-subtitle { font-size: 1rem; color: var(--color-muted); text-align: center; margin-bottom: 1.5rem; }


/* --- Attachment Section (_AttachmentSection partial) --- */

/* Chip list — flex row of removable chips */
.att-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    min-height: 0;
}
.att-chip {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    font-size: .78rem;
    line-height: 1.3;
    max-width: 260px;
}
.att-chip-icon { flex-shrink: 0; }
.att-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.att-chip-remove {
    flex-shrink: 0;
    padding: 0 .15rem;
    border: none;
    background: transparent;
    color: var(--color-muted);
    font-size: .85rem;
    cursor: pointer;
    line-height: 1;
}
.att-chip-remove:hover { color: var(--color-danger); }

/* Picker wrap — hidden inline panel shown after clicking "+ Add" */
.att-picker-inner {
    font-size: .85rem;
}
.ap-report-or {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--color-muted);
    font-size: .78rem;
    margin: .4rem 0;
}
.ap-report-or::before,
.ap-report-or::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--color-border);
}

/* Library quick-pick panel */
.att-library-panel {
    margin-top: .5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    font-size: .82rem;
    max-width: 520px;
}
.ap-library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .4rem .75rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-alt);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.ap-library-close {
    border: none;
    background: transparent;
    font-size: .9rem;
    cursor: pointer;
    color: var(--color-muted);
    padding: 0 .2rem;
}
.ap-library-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 220px;
    overflow-y: auto;
}
.ap-library-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .75rem;
    border: none;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-size: .82rem;
    transition: background .1s;
}
.ap-library-item:last-child { border-bottom: none; }
.ap-library-item:hover { background: var(--color-primary-muted); }
.ap-lib-icon { flex-shrink: 0; }
.ap-lib-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.ap-library-footer {
    padding: .35rem .75rem;
    border-top: 1px solid var(--color-border);
    text-align: right;
    background: var(--color-surface-alt);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}
