/* ══════════════════════════════════════════
   Elite Creed — Components
   ══════════════════════════════════════════ */

/* ── Buttons ── */
.btn {
    font-family: var(--font-body);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-body);
    padding: 0.625rem 1.5rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.08);
    opacity: 0;
    transition: opacity var(--duration-fast);
}
.btn:hover::after { opacity: 1; }
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn:disabled::after { display: none; }

.btn-gold {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-strong));
    color: var(--color-bg-900);
    box-shadow: var(--shadow-gold);
}
.btn-gold:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 48px rgba(255, 215, 0, 0.28);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: var(--color-bg-900);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-surface-700);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border-soft);
}
.btn-secondary:hover {
    background: var(--color-surface-600);
    border-color: var(--color-border-medium);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--color-border-medium);
    color: var(--color-primary);
}
.btn-outline:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-dim);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-success {
    background: #22bb33;
    color: #fff;
}

.btn-sm { font-size: var(--fs-small); padding: 0.4rem 1rem; }
.btn-lg { font-size: 1.125rem; padding: 0.875rem 2rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0.5rem; width: 36px; height: 36px; }

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    border: 1px solid var(--color-border-soft);
    transition: box-shadow var(--duration-normal) var(--ease-out),
                transform var(--duration-normal) var(--ease-out);
}
.card:hover {
    box-shadow: var(--shadow-md);
}

.card-stat {
    position: relative;
    overflow: hidden;
}
.card-stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary-strong), var(--color-primary));
}
.card-stat__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--color-primary-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: var(--space-4);
}
.card-stat__value {
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: var(--fw-bold);
    color: var(--color-text-primary);
    line-height: 1;
}
.card-stat__label {
    font-size: var(--fs-small);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
}
.card-stat__trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--fs-xs);
    margin-top: var(--space-2);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}
.card-stat__trend--up {
    color: var(--color-success);
    background: var(--color-success-bg);
}
.card-stat__trend--down {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.badge-success {
    color: var(--color-success-text);
    background: var(--color-success-bg);
}
.badge-warning {
    color: var(--color-warning-text);
    background: var(--color-warning-bg);
}
.badge-danger {
    color: var(--color-danger-text);
    background: var(--color-danger-bg);
}
.badge-info {
    color: var(--color-info-text);
    background: var(--color-info-bg);
}
.badge-default {
    color: var(--color-text-muted);
    background: rgba(255,255,255,0.06);
}
.badge-gold {
    color: var(--color-bg-900);
    background: var(--color-primary);
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-soft);
    background: var(--bg-card);
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}
th, td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--fs-small);
    border-bottom: 1px solid var(--color-border-soft);
}
th {
    background: rgba(255,255,255,0.03);
    font-weight: var(--fw-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: var(--fs-xs);
    letter-spacing: 0.05em;
}
tr:last-child td { border-bottom: none; }
tr:hover td {
    background: rgba(255,255,255,0.02);
}

/* ── Modals ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.is-open { display: flex; }

.modal {
    background: var(--color-surface-700);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--color-border-medium);
    box-shadow: var(--shadow-lg);
}
.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}
.modal__title {
    font-size: var(--fs-h4);
    font-weight: var(--fw-bold);
}
.modal__close {
    font-size: 1.25rem;
    color: var(--color-text-muted);
    transition: color var(--duration-fast);
}
.modal__close:hover { color: var(--color-text-primary); }
.modal__body { margin-bottom: var(--space-6); }
.modal__footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* ── Toasts ── */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.toast {
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--fs-small);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-md);
    animation: fadeSlideUp 0.3s var(--ease-out);
    max-width: 380px;
    border: 1px solid var(--color-border-soft);
}
.toast--success { background: rgba(34,187,51,0.9); }
.toast--error   { background: rgba(255,68,68,0.9); }
.toast--warning { background: rgba(255,165,0,0.9); color: var(--color-bg-900); }
.toast--info    { background: rgba(135,206,235,0.9); color: var(--color-bg-900); }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--color-text-muted);
}
.empty-state__icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.4;
}
.empty-state__text {
    font-size: var(--fs-body);
    margin-bottom: var(--space-4);
}

/* ── Progress Bar ── */
.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary-strong), var(--color-primary));
    border-radius: var(--radius-full);
    transition: width 0.6s var(--ease-out);
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--color-border-soft);
    margin-bottom: var(--space-6);
    overflow-x: auto;
}
.tab {
    padding: var(--space-3) var(--space-5);
    font-size: var(--fs-small);
    font-weight: var(--fw-medium);
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    transition: all var(--duration-fast);
    white-space: nowrap;
    cursor: pointer;
}
.tab:hover { color: var(--color-text-primary); }
.tab.is-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ── Pulse Dot ── */
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success);
    animation: pulse 2s ease-in-out infinite;
}

/* ── Avatar ── */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-strong));
    color: var(--color-bg-900);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--fw-bold);
    font-size: var(--fs-small);
    flex-shrink: 0;
}
.avatar--sm { width: 32px; height: 32px; font-size: var(--fs-xs); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-h4); }

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-6);
    justify-content: center;
}
.pagination__btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-small);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-soft);
    transition: all var(--duration-fast);
}
.pagination__btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.pagination__btn.is-active {
    background: var(--color-primary);
    color: var(--color-bg-900);
    border-color: var(--color-primary);
}

/* ── Stepper (loan status) ── */
.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: var(--space-4) 0;
}
.stepper__step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    white-space: nowrap;
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}
.stepper__step.is-active {
    color: var(--color-primary);
}
.stepper__step.is-completed {
    color: var(--color-success);
}
.stepper__dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--color-border-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xs);
    flex-shrink: 0;
}
.stepper__step.is-active .stepper__dot {
    border-color: var(--color-primary);
    background: var(--color-primary-dim);
    color: var(--color-primary);
}
.stepper__step.is-completed .stepper__dot {
    border-color: var(--color-success);
    background: var(--color-success-bg);
    color: var(--color-success);
}
.stepper__line {
    width: 30px;
    height: 2px;
    background: var(--color-border-soft);
    flex-shrink: 0;
    margin: 0 var(--space-1);
}
.stepper__step.is-completed + .stepper__line {
    background: var(--color-success);
}

/* Compatibility classes used across dashboard pages */
.btn--primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: var(--color-bg-900);
    box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn--outline {
    background: transparent;
    border: 1.5px solid var(--color-border-medium);
    color: var(--color-primary);
}
.btn--outline:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-dim);
}
.btn--danger {
    background: var(--color-danger);
    color: #fff;
}
.btn--success {
    background: #22bb33;
    color: #fff;
}
.btn--ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid transparent;
}
.btn--ghost:hover {
    color: var(--color-primary);
    background: rgba(255,255,255,0.04);
}
.btn--sm { font-size: var(--fs-small); padding: 0.4rem 1rem; }
.btn--lg { font-size: 1.125rem; padding: 0.875rem 2rem; }
.btn--block { width: 100%; }

.card__header,
.card__footer {
    padding: var(--space-5) var(--space-6);
}
.card__header {
    border-bottom: 1px solid var(--color-border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.card__footer {
    border-top: 1px solid var(--color-border-soft);
}
.card__body {
    padding: var(--space-6);
}
.card__body--no-padding {
    padding: 0;
}
.card__title {
    font-size: var(--fs-h4);
    font-weight: var(--fw-semibold);
    color: var(--color-text-primary);
}
.card__actions,
.btn-group,
.action-buttons,
.content-header__left,
.content-header__actions,
.pagination__links {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.stat-card {
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary-strong), var(--color-primary));
}
.stat-card__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--color-primary-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: var(--space-4);
}
.stat-card__value {
    font-family: var(--font-display);
    font-size: var(--fs-h2);
    font-weight: var(--fw-bold);
    color: var(--color-text-primary);
    line-height: 1;
}
.stat-card__label {
    font-size: var(--fs-small);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
}

/* Stat card needs card appearance when used standalone */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    border: 1px solid var(--color-border-soft);
}

/* Stat card icon color modifiers */
.stat-card__icon--primary { background: var(--color-primary-dim); color: var(--color-primary); }
.stat-card__icon--info    { background: var(--color-info-bg); color: var(--color-info); }
.stat-card__icon--success { background: var(--color-success-bg); color: var(--color-success); }
.stat-card__icon--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-card__icon--danger  { background: var(--color-danger-bg); color: var(--color-danger); }

/* Content row (side-by-side cards) */
.content-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}
@media (min-width: 768px) {
    .content-row { grid-template-columns: repeat(2, 1fr); }
}

/* Half-width card variant */
.card--half {
    min-width: 0;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-soft);
    background: var(--bg-card);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    /* Reset old app.min.css rules that style .modal as content panel */
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    width: auto;
    max-width: none;
    max-height: none;
    overflow: visible;
    margin: 0;
}
/* Restore .modal styles when used as content panel inside .modal-overlay (old pattern) */
.modal-overlay > .modal {
    display: block;
    position: relative;
    inset: auto;
    background: var(--color-surface-700);
    border-radius: var(--radius-xl);
    width: min(100%, 520px);
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--color-border-medium);
    box-shadow: var(--shadow-lg);
    padding: var(--space-8);
    margin: 0;
}
.modal.is-open,
.modal.is-active {
    display: flex;
}
.modal__overlay,
.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.modal__container,
.modal__content {
    position: relative;
    z-index: 1;
    background: var(--color-surface-700);
    border-radius: var(--radius-xl);
    width: min(100%, 520px);
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--color-border-medium);
    box-shadow: var(--shadow-lg);
    padding: var(--space-8);
}

.form-actions,
.modal__footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    flex-wrap: wrap;
}

.tab--active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}
.tab__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    padding: 0 0.4rem;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.08);
    color: var(--color-text-secondary);
    font-size: var(--fs-xs);
    margin-left: var(--space-2);
}

.content-header,
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-6);
}
.toolbar__search {
    width: 100%;
}
.input-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.input-group > .form-input {
    flex: 1;
    min-width: 220px;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.user-cell__avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-strong));
    color: var(--color-bg-900);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-small);
    font-weight: var(--fw-bold);
    flex-shrink: 0;
}
.user-cell__name,
.detail-item__value,
.detail-value {
    display: block;
    color: var(--color-text-primary);
    font-weight: var(--fw-medium);
}
.user-cell__email,
.detail-item__label,
.detail-label {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--fs-xs);
}

.detail-grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.detail-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.form-grid {
    display: grid;
    gap: var(--space-4);
}
.form-grid--2 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.form-grid--3 {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.form-group--inline {
    margin-bottom: 0;
}
.settings-form {
    display: grid;
    gap: var(--space-6);
}
.filter-row {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.market-grid {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    min-height: 240px;
    text-align: center;
    color: var(--color-text-muted);
}

.pagination__info {
    color: var(--color-text-muted);
    font-size: var(--fs-small);
}

.form-alert,
.alert {
    display: block;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-soft);
    margin-bottom: var(--space-4);
    font-size: var(--fs-small);
}
.form-alert--error,
.alert--warning {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}
.form-alert--success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}
