/**
 * Skeleton placeholders – BEM, reusable across views.
 * Used for initial page load before content is revealed.
 */

/* Base block */
.skeleton {
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.skeleton--shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: skeleton-shimmer 1.8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes skeleton-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Line element – heights and width variants */
.skeleton__line {
    background-color: #e5e7eb;
    border-radius: 4px;
    height: 1rem;
    display: block;
}

.skeleton__line--short {
    width: 25%;
}

.skeleton__line--medium {
    width: 55%;
}

.skeleton__line--long {
    width: 85%;
}

.skeleton__line--full {
    width: 100%;
}

.skeleton__line--w220 {
    width: 220px;
}

.skeleton__line--w160 {
    width: 160px;
}

.skeleton__line--title-block {
    height: 28px;
    width: 280px;
    display: inline-block;
}

.skeleton__line--badge-block {
    width: 80px;
    height: 28px;
    border-radius: 20px;
    display: inline-block;
}

.skeleton__line--btn-block {
    width: 140px;
    height: 38px;
    border-radius: 6px;
    display: inline-block;
}

.skeleton__line--icon-block {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    flex-shrink: 0;
}

.skeleton__line--tariff-caption {
    width: 45%;
    height: 10px;
}

.skeleton__line--tariff-name {
    width: 55%;
    height: 20px;
}

.skeleton__line--tariff-badge {
    width: 35%;
    height: 12px;
}

.skeleton__line--sm {
    height: 0.75rem;
}

.skeleton__line--lg {
    height: 1.25rem;
}

/* Placeholder wrapper – hidden when content is shown */
.skeleton-placeholder {
    transition: opacity 0.2s ease;
}

.skeleton-placeholder--hidden {
    display: none !important;
}

/* Content hidden until ready */
.page-content--hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.page-content--visible {
    opacity: 1;
    visibility: visible;
}

/* Table variant – matches userDatatable / registrations-table proportions */
.skeleton-table {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.skeleton-table__header {
    display: flex;
    gap: 16px;
    padding: 14px 16px;
    background-color: #f8f9fb;
    border-bottom: 2px solid #e6e8ee;
}

.skeleton-table__header-cell {
    flex: 1;
    min-width: 0;
    max-width: 120px;
    height: 11px;
    background-color: #d1d5db;
    border-radius: 4px;
}

.skeleton-table__body {
    padding: 0;
}

.skeleton-table__row {
    display: flex;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f2f6;
    align-items: center;
}

.skeleton-table__row:last-child {
    border-bottom: none;
}

.skeleton-table__cell {
    flex: 1;
    min-width: 0;
    max-width: 140px;
    height: 14px;
    background-color: #e5e7eb;
    border-radius: 4px;
}

.skeleton-table .skeleton--shimmer::after {
    border-radius: 0;
}

/* Native table skeleton – used inside real <table> so column widths match the real table */
.skeleton-table-native__wrap {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.skeleton-table-native {
    width: 100%;
}

.skeleton-table-native th,
.skeleton-table-native td {
    vertical-align: middle;
}

.skeleton-placeholder .skeleton-table-native th,
.skeleton-placeholder .skeleton-table-native td {
    padding-top: 6px;
    padding-bottom: 6px;
    padding-left: 10px;
    padding-right: 10px;
}

.skeleton-placeholder .skeleton-table-native thead th {
    border-bottom: 2px solid #e6e8ee;
    background-color: #f8f9fb;
}

.skeleton-placeholder .skeleton-table-native tbody td {
    border-bottom: 1px solid #e6e8ee;
}

.skeleton-placeholder .skeleton-table-native tbody tr:nth-child(even) td {
    background-color: #fafbfc;
}

.skeleton-placeholder .skeleton-table-native tbody tr:nth-child(odd) td {
    background-color: #fff;
}

.skeleton-table-native__cell {
    display: block;
    width: 70%;
    min-width: 40px;
    height: 10px;
}

.skeleton-table-native thead .skeleton-table-native__cell {
    width: 50%;
    height: 10px;
}

/* Hide optional header block inside skeleton placeholder (e.g. adv-table-table__header) */
.skeleton-placeholder .adv-table-table__header {
    display: none;
}

/* Detail variant – header + cards */
.skeleton-detail {
    background: transparent;
}

.skeleton-detail__header {
    margin-bottom: 24px;
}

.skeleton-detail__title {
    height: 1.75rem;
    width: 60%;
    background-color: #e5e7eb;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-detail__subtitle {
    height: 0.875rem;
    width: 30%;
    background-color: #e5e7eb;
    border-radius: 4px;
}

.skeleton-detail__card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.skeleton-detail__card-title {
    height: 1rem;
    width: 40%;
    background-color: #e5e7eb;
    border-radius: 4px;
    margin-bottom: 16px;
}

.skeleton-detail__card-line {
    height: 0.875rem;
    background-color: #e5e7eb;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-detail__card-line:last-child {
    margin-bottom: 0;
}

.skeleton-detail__card-line--short {
    width: 35%;
}

.skeleton-detail__card-line--medium {
    width: 70%;
}

/* Form variant */
.skeleton-form {
    max-width: 640px;
}

.skeleton-form__group {
    margin-bottom: 20px;
}

.skeleton-form__label {
    height: 0.75rem;
    width: 25%;
    background-color: #e5e7eb;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-form__input {
    height: 2.25rem;
    width: 100%;
    background-color: #e5e7eb;
    border-radius: 6px;
}

.skeleton-form__button {
    margin-top: 24px;
    height: 2.5rem;
    width: 140px;
    background-color: #d1d5db;
    border-radius: 6px;
}

/* Cards grid variant */
.skeleton-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.skeleton-cards__card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.skeleton-cards__card-title {
    height: 1.25rem;
    width: 70%;
    background-color: #e5e7eb;
    border-radius: 4px;
    margin-bottom: 12px;
}

.skeleton-cards__card-line {
    height: 0.875rem;
    background-color: #e5e7eb;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-cards__card-line:last-child {
    margin-bottom: 0;
}

.skeleton-cards__card-line--w60 {
    width: 60%;
}

.skeleton-cards__card-line--w80 {
    width: 80%;
}

/* Inline table skeleton rows – for AJAX loading state inside existing tables */
.skeleton-table-inline td {
    padding: 6px 10px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f2f6;
}

.skeleton-table-inline .skeleton__line {
    width: 70%;
    height: 10px;
    display: block;
}

/* Main header: no skeleton, subtle entrance from top with delay */
.header-top--animate {
    animation: header-subtle-in-from-top 0.5s ease-out 0.2s both;
}

@keyframes header-subtle-in-from-top {
    from {
        opacity: 0.96;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Layout skeletons – sidebar load first, then reveal real nav */
.layout-skeleton-placeholder {
    transition: opacity 0.2s ease;
}

body.layout-ready .layout-skeleton-placeholder {
    display: none !important;
}

body.layout-ready .layout-content--hidden {
    opacity: 1 !important;
    visibility: visible !important;
}

.layout-content--hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Header skeleton – matches .header-top height (72px) and .navbar structure */
.skeleton-layout-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9987;
    height: 72px;
    background: #fff;
    border-bottom: 1px solid #e6e8ee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.skeleton-layout-header__left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.skeleton-layout-header__logo {
    width: 120px;
    height: 32px;
    border-radius: 4px;
    background-color: #e5e7eb;
}

.skeleton-layout-header__nav {
    display: flex;
    gap: 16px;
}

.skeleton-layout-header__nav-item {
    width: 72px;
    height: 20px;
    border-radius: 4px;
    background-color: #e5e7eb;
}

.skeleton-layout-header__right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.skeleton-layout-header__search {
    width: 180px;
    height: 36px;
    border-radius: 6px;
    background-color: #e5e7eb;
}

.skeleton-layout-header__user {
    width: 100px;
    height: 36px;
    border-radius: 6px;
    background-color: #e5e7eb;
}

/* Sidebar skeleton – matches .sidebar (280px, top 72px) */
.skeleton-layout-sidebar {
    position: fixed;
    left: 0;
    top: 72px;
    width: 280px;
    height: calc(100% - 72px);
    padding: 20px 16px;
    background: #fff;
    border-right: 1px solid #e6e8ee;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.06);
}

.skeleton-layout-sidebar__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
}

.skeleton-layout-sidebar__icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background-color: #e5e7eb;
    flex-shrink: 0;
}

.skeleton-layout-sidebar__text {
    height: 16px;
    border-radius: 4px;
    background-color: #e5e7eb;
    flex: 1;
    max-width: 140px;
}
