/**
 * YellowPage.pk - Content-Based Loader System (CSS)
 * 60fps GPU-accelerated Shimmer Animations & Exact-dimension Skeletons
 */

/* 1. Global Shimmer Keyframe (Compositor-accelerated) */
@keyframes ypShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.yp-shimmer-base,
html[data-theme="light"] .yp-shimmer-base {
    background: linear-gradient(90deg, #E2E8F0 0%, #F8FAFC 50%, #E2E8F0 100%);
    background-size: 200% 100%;
    animation: ypShimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* Dark Theme Shimmer for Admin Panel */
html[data-theme="dark"] .yp-shimmer-base,
.admin-dark .yp-shimmer-base,
html:not([data-theme="light"]) .admin-body .yp-shimmer-base {
    background: linear-gradient(90deg, #1E293B 0%, #334155 50%, #1E293B 100%);
    background-size: 200% 100%;
}

html[data-theme="dark"] .admin-body .yp-skeleton-row {
    border-bottom: 1px solid #2A2A2A;
}

html[data-theme="light"] .admin-body .yp-skeleton-row {
    border-bottom: 1px solid #E2E8F0;
}

/* 2. Top Progress Bar (3px Gold Accent) */
#ypTopProgressBar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #FFD700 0%, #F59E0B 100%);
    z-index: 99999;
    transition: width 0.25s ease, opacity 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    pointer-events: none;
    opacity: 0;
}
#ypTopProgressBar.active {
    opacity: 1;
}

/* 3. Type 1: Skeleton Listing Cards (Matches .yp-listing-card exact dimensions) */
.yp-skeleton-card-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.yp-skeleton-card {
    background: #FFFFFF;
    border-radius: 12px;
    border: 1px solid #E2E8F0;
    border-left: 5px solid #CBD5E1;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
    min-height: 180px;
}

.yp-skeleton-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.yp-skeleton-badge {
    width: 140px;
    height: 36px;
    border-radius: 8px;
}

.yp-skeleton-card-body {
    display: flex;
    align-items: center;
    gap: 20px;
}

.yp-skeleton-col-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100px;
    flex-shrink: 0;
}

.yp-skeleton-logo {
    width: 100px;
    height: 100px;
    border-radius: 10px;
    flex-shrink: 0;
}

.yp-skeleton-socials {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.yp-skeleton-social-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.yp-skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.yp-skeleton-line-title {
    width: 70%;
    height: 22px;
    border-radius: 4px;
}

.yp-skeleton-line-desc {
    width: 90%;
    height: 14px;
    border-radius: 4px;
}

.yp-skeleton-line-meta {
    width: 45%;
    height: 14px;
    border-radius: 4px;
}

.yp-skeleton-col-action {
    width: 190px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.yp-skeleton-map {
    width: 100%;
    height: 80px;
    border-radius: 8px;
}

.yp-skeleton-btn {
    width: 100%;
    height: 38px;
    border-radius: 6px;
}

/* Mobile Responsive Adjustments for Skeleton Cards (375px) */
@media (max-width: 767.98px) {
    .yp-skeleton-card {
        padding: 14px;
        gap: 12px;
    }
    .yp-skeleton-card-body {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }
    .yp-skeleton-col-logo {
        width: 100%;
    }
    .yp-skeleton-logo {
        width: 80px;
        height: 80px;
    }
    .yp-skeleton-line-title {
        width: 85%;
        height: 18px;
    }
    .yp-skeleton-line-desc {
        width: 100%;
        height: 12px;
    }
    .yp-skeleton-line-meta {
        width: 60%;
        height: 12px;
    }
    .yp-skeleton-col-action {
        width: 100%;
        padding-top: 10px;
        border-top: 1px solid #F1F5F9;
    }
}

/* 4. Type 2: Skeleton Table Rows (Matches .admin-table rows 58px height) */
.yp-skeleton-table-wrap {
    width: 100%;
}

.yp-skeleton-row {
    height: 58px;
    border-bottom: 1px solid var(--border-color, #E2E8F0);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    width: 100%;
}

.yp-skeleton-col {
    height: 16px;
    border-radius: 4px;
}

/* 5. Type 3: Skeleton Tiles (Matches Category Grid Tiles) */
.yp-skeleton-tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    width: 100%;
}

.yp-skeleton-tile {
    background: #FFFFFF;
    border-radius: 12px;
    border: 1px solid #E2E8F0;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 80px;
}

.yp-skeleton-tile-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    flex-shrink: 0;
}

.yp-skeleton-tile-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.yp-skeleton-tile-title {
    width: 75%;
    height: 16px;
}

.yp-skeleton-tile-count {
    width: 35%;
    height: 12px;
}

/* 6. Type 4: Skeleton Profile (Listing Detail Page Preview) */
.yp-skeleton-profile-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.yp-skeleton-hero {
    height: 220px;
    border-radius: 16px;
    width: 100%;
}

.yp-skeleton-profile-card {
    background: #FFFFFF;
    border-radius: 14px;
    border: 1px solid #E2E8F0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 7. Type 5: Inline Loaders (Button & Input Spinners) */
.yp-btn-loading {
    position: relative !important;
    pointer-events: none !important;
    color: transparent !important;
}

.yp-btn-loading .yp-btn-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,0,0,0.2);
    border-top-color: #0A0A0A;
    border-radius: 50%;
    animation: ypSpin 0.6s linear infinite;
}

.btn-dark .yp-btn-spinner,
.btn-primary .yp-btn-spinner,
.btn-admin .yp-btn-spinner,
.btn-admin-danger .yp-btn-spinner,
.btn-admin-success .yp-btn-spinner {
    border-color: rgba(255, 255, 255, 0.25) !important;
    border-top-color: #FFFFFF !important;
}

@keyframes ypSpin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes ypSpinInline {
    to { transform: rotate(360deg); }
}

/* Input Spinner (Right edge) */
.yp-input-spinner-wrap {
    position: relative;
}

.yp-input-spinner {
    position: absolute;
    right: 12px;
    top: 50%;
    margin-top: -7px;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-top-color: #0A0A0A;
    border-radius: 50%;
    animation: ypSpinInline 0.6s linear infinite;
    display: none;
    z-index: 5;
}

.yp-input-spinner.active {
    display: block;
}

/* Button Success Checkmark State */
.yp-btn-success-state {
    background-color: #10B981 !important;
    border-color: #10B981 !important;
    color: #FFFFFF !important;
    transition: all 0.2s ease;
}

/* Button Error State */
.yp-btn-error-state {
    background-color: #EF4444 !important;
    border-color: #EF4444 !important;
    color: #FFFFFF !important;
}
