/*
 * Fateel "Shrara" components (resources/views/components/ui/*).
 * Colors come from fateel-tokens.css, so every rule works in light and dark.
 */

/* Status badge: a soft pill with a dot */
.fx-chip {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    height: 1.75rem;
    padding-inline: .75rem;
    border-radius: var(--fx-radius-pill);
    font-size: .75rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    background: var(--fx-surface-2);
    color: var(--fx-muted);
}
.fx-chip::before {
    content: "";
    width: .4375rem;
    height: .4375rem;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
.fx-chip-ok { background: var(--fx-success-soft); color: var(--fx-success-ink); }
.fx-chip-warn { background: var(--fx-warning-soft); color: var(--fx-warning-ink); }
.fx-chip-bad { background: var(--fx-danger-soft); color: var(--fx-danger-ink); }
.fx-chip-info { background: var(--fx-info-soft); color: var(--fx-info-ink); }

/* Number tile */
.fx-stat {
    display: grid;
    gap: .625rem;
    align-content: start;
    padding: 1rem 1.125rem;
    border: 1px solid var(--fx-border);
    border-radius: 1rem;
    box-shadow: none;
    color: inherit;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
a.fx-stat:hover { border-color: var(--fx-table-head-border); box-shadow: var(--fx-shadow-1); color: inherit; }
.fx-stat-top { display: flex; align-items: center; gap: .625rem; }
.fx-stat-icon {
    width: 2.125rem;
    height: 2.125rem;
    border-radius: .625rem;
    display: grid;
    place-items: center;
    background: var(--fx-primary-100);
    color: var(--fx-primary-ink);
    font-size: 1.125rem;
}
.fx-stat-label { font-size: .8125rem; font-weight: 600; color: var(--fx-muted); }
.fx-stat-value { margin: 0; font-size: 1.875rem; font-weight: 700; line-height: 1.15; color: var(--fx-heading); }
.fx-stat-value small { font-size: .85rem; font-weight: 500; color: var(--fx-muted); margin-inline-start: .375rem; }
.fx-stat-foot { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .8125rem; color: var(--fx-muted); }

/* Meter with a track from the same ramp */
.fx-meter { height: .5rem; border-radius: 99px; background: var(--fx-primary-200); overflow: hidden; }
.fx-meter > span { display: block; height: 100%; border-radius: 99px; background: var(--fx-primary); }

/* Page header */
.fx-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.fx-page-title { margin: 0; font-size: 1.625rem; font-weight: 700; color: var(--fx-heading); }
.fx-page-subtitle { margin: .375rem 0 0; font-size: .875rem; color: var(--fx-muted); }
.fx-crumbs { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; font-size: .8125rem; color: var(--fx-muted); margin-bottom: .25rem; }
.fx-crumbs a { color: var(--fx-muted); }
.fx-crumbs a:hover { color: var(--fx-primary-ink); }
.fx-crumbs .ti:last-child { display: none; }
.fx-page-actions { display: flex; gap: .625rem; flex-wrap: wrap; }

/* Page-level pill buttons: white (soft) and deep burgundy (the main action) */
.btn.fx-btn-soft,
.btn.fx-btn-deep {
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding-inline: 1.25rem;
    border: 0;
    border-radius: var(--fx-radius-pill);
    font-size: .875rem;
    font-weight: 600;
    transition: transform .2s ease, box-shadow .2s ease;
}
.btn.fx-btn-soft { background: var(--fx-surface); color: var(--fx-heading); box-shadow: 0 0 0 1px var(--fx-border); }
.btn.fx-btn-soft .ti { font-size: 1.125rem; color: var(--fx-faint); }
.btn.fx-btn-soft:hover { color: var(--fx-primary-ink); box-shadow: 0 0 0 1px var(--fx-table-head-border); }
.btn.fx-btn-deep { background: var(--fx-glow-deep); color: var(--fx-on-primary); box-shadow: 0 14px 28px -14px rgba(var(--fx-primary-rgb), .75); }
.btn.fx-btn-deep .ti { font-size: 1.125rem; }
.btn.fx-btn-soft:hover,
.btn.fx-btn-deep:hover { transform: translateY(-1px); }
.btn.fx-btn-deep:hover { color: var(--fx-on-primary); }

/* List toolbar: status tabs on one side, filters on the other */
.fx-list-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.fx-list-filters { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.fx-list-filters > .form-select { width: auto; min-width: 9.5rem; height: 2.75rem; border-radius: var(--fx-radius-pill); border: 0; box-shadow: 0 0 0 1px var(--fx-border); background-color: var(--fx-surface); }
.fx-list-filter-roles { width: 14rem; }
.fx-list-filter-roles .select2-container--default .select2-selection { min-height: 2.75rem; border: 0; border-radius: var(--fx-radius-pill) !important; background-color: var(--fx-surface); box-shadow: 0 0 0 1px var(--fx-border); }

/* Segmented tabs with counts */
.fx-seg { display: inline-flex; gap: .25rem; padding: .3125rem; border-radius: var(--fx-radius-pill); background: var(--fx-surface); box-shadow: 0 0 0 1px var(--fx-border); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.fx-seg::-webkit-scrollbar { display: none; }
.fx-seg > button {
    flex: none;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding-inline: 1rem;
    border: 0;
    border-radius: var(--fx-radius-pill);
    background: transparent;
    color: var(--fx-muted);
    font-size: .875rem;
    transition: background-color .15s ease, color .15s ease;
}
.fx-seg > button > span { font-size: .75rem; color: var(--fx-faint); font-variant-numeric: tabular-nums; }
.fx-seg > button:hover { color: var(--fx-heading); }
.fx-seg > button.is-active { background: var(--fx-primary); color: var(--fx-on-primary); font-weight: 600; box-shadow: 0 10px 20px -12px rgba(var(--fx-primary-rgb), .8); }
.fx-seg > button.is-active > span { color: var(--fx-primary-200); }

/* Search field as a pill */
.fx-search-pill {
    height: 2.75rem;
    width: 17rem;
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding-inline: 1rem;
    border-radius: var(--fx-radius-pill);
    background: var(--fx-surface);
    box-shadow: 0 0 0 1px var(--fx-border);
    color: var(--fx-faint);
    margin: 0;
}
.fx-search-pill:focus-within { box-shadow: 0 0 0 1px var(--fx-crimson), 0 0 0 .25rem var(--fx-ring); }
.fx-search-pill input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--fx-heading); font-size: .875rem; }
.fx-search-pill input::placeholder { color: var(--fx-faint); }

/* DataTables footer (length, info, pages) in one quiet row */
.fx-dt-foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1.25rem; flex-wrap: wrap; padding: .75rem .75rem .25rem; }
.fx-dt-foot .dataTables_info { padding: 0 !important; margin-inline-end: auto; }
.fx-dt-foot .dataTables_paginate { margin: 0 !important; }
.fx-dt-foot .pagination { margin: 0 !important; }
th.fx-check-col,
td.fx-check-col { width: 2.75rem; text-align: center; padding-inline: .75rem !important; }

/* Avatar with a white ring, as in the tables of the soft look */
.fx-avatar-ring .avatar-initial,
.fx-avatar-ring img { box-shadow: 0 0 0 3px var(--fx-surface), 0 0 0 4px var(--fx-border); font-size: .75rem; font-weight: 700; }

/* Floating bar for picked rows (<x-ui.bulk-bar>) */
.fx-bulk {
    position: sticky;
    bottom: 1.25rem;
    z-index: 5;
    width: max-content;
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: .25rem;
    margin: 1rem auto 0;
    padding: .4375rem;
    border-radius: var(--fx-radius-pill);
    background: rgba(61, 6, 33, .92);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 30px 60px -20px rgba(74, 8, 40, .7);
    color: #fff;
    white-space: nowrap;
    animation: fx-bulk-rise .3s cubic-bezier(.2, .8, .2, 1);
}
.fx-bulk[hidden] { display: none; }
.fx-bulk-count { display: inline-flex; align-items: center; gap: .5rem; height: 2.375rem; padding-inline: .5rem .875rem; font-size: .875rem; font-weight: 600; }
.fx-bulk-count b { min-width: 1.625rem; height: 1.625rem; display: grid; place-items: center; padding-inline: .375rem; border-radius: var(--fx-radius-pill); background: #fff; color: var(--fx-rail-on-ink); font-size: .8rem; }
.fx-bulk > button {
    height: 2.375rem;
    display: inline-flex;
    align-items: center;
    gap: .4375rem;
    padding-inline: .875rem;
    border: 0;
    border-radius: var(--fx-radius-pill);
    background: transparent;
    color: #fff;
    font-size: .875rem;
}
.fx-bulk > button:hover { background: rgba(255, 255, 255, .1); }
.fx-bulk > button .ti { font-size: 1.0625rem; color: #ffb3c1; }
.fx-bulk > .fx-bulk-clear { width: 2.375rem; padding: 0; justify-content: center; background: rgba(255, 255, 255, .1); }
.fx-bulk > .fx-bulk-clear .ti { color: #fff; }
@keyframes fx-bulk-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (max-width: 991.98px) {
    .fx-bulk { bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px)); overflow-x: auto; }
}

.fx-export-note { margin: 0 0 1rem; padding: .625rem 1rem; border-radius: var(--fx-radius-field); background: var(--fx-tint); color: var(--fx-primary-ink); font-weight: 600; font-size: .875rem; }

/* Empty state */
.fx-empty { display: grid; justify-items: center; text-align: center; gap: .375rem; padding: 2rem 1rem; border-radius: 1rem; background: var(--fx-surface-2); }
.fx-empty-mark { width: 2.5rem; height: 3.25rem; margin-bottom: .25rem; }
.fx-empty-title { margin: 0; font-size: 1rem; font-weight: 700; color: var(--fx-heading); }
.fx-empty-text { margin: 0; font-size: .875rem; color: var(--fx-muted); }

/* Spark loader */
.fx-spark-loader { display: inline-flex; align-items: center; }
.fx-spark-loader svg { width: 2.25rem; height: 2.9rem; }
.fx-spark-loader .fx-ray { animation: fx-ray 1.6s ease-in-out infinite; }
.fx-spark-loader .fx-ray:nth-of-type(3) { animation-delay: 0s; }
.fx-spark-loader .fx-ray:nth-of-type(4) { animation-delay: .12s; }
.fx-spark-loader .fx-ray:nth-of-type(5) { animation-delay: .24s; }
.fx-spark-loader .fx-ray:nth-of-type(6) { animation-delay: .36s; }
.fx-spark-loader .fx-ray:nth-of-type(7) { animation-delay: .48s; }
@keyframes fx-ray { 0%, 100% { opacity: .2; } 35%, 55% { opacity: 1; } }

/* Keyboard focus ring in the brand crimson */
.btn:focus-visible,
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 .25rem var(--fx-ring);
}

@media (prefers-reduced-motion: reduce) {
    .fx-spark-loader .fx-ray { animation: none; opacity: 1; }
    .fx-bulk { animation: none; }
}

/*
 * Dark-mode safety net for pages that still use light-only utilities
 * (bg-white / bg-light / text-dark). Pages are cleaned up as they move to the
 * new components; until then these keep them readable in "midnight".
 */
.dark-style .bg-white,
.dark-style .bg-body { background-color: var(--fx-surface) !important; }
.dark-style .bg-light,
.dark-style .bg-lighter { background-color: var(--fx-surface-2) !important; }
.dark-style .text-dark,
.dark-style .text-black { color: var(--fx-heading) !important; }
.dark-style .border-white { border-color: var(--fx-border) !important; }
