/* =============================================
   PERFORMANCE OPTIMIZATIONS
   Smooth animations, hardware acceleration, 
   loading states
   ============================================= */

/* GPU Acceleration for animated elements */
.btn,
.recording-item,
.plan-card,
.limits-card,
.key-card,
.payment-method,
.history-item,
.faq-item,
.profile-btn,
.pricing-card {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Smooth transitions globally */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Optimized transitions */
.btn {
    transition: transform 0.15s ease-out,
        background-color 0.15s ease-out,
        box-shadow 0.15s ease-out,
        opacity 0.15s ease-out;
    will-change: transform;
}

.btn:active {
    transform: scale(0.97) translateZ(0);
}

/* Cards smooth hover */
.recording-item,
.pricing-card,
.payment-method,
.faq-item {
    transition: transform 0.2s ease-out,
        box-shadow 0.2s ease-out,
        background-color 0.2s ease-out;
}

.recording-item:active,
.pricing-card:active,
.payment-method:active {
    transform: scale(0.98) translateZ(0);
}

/* Smooth progress bars */
.limits-bar,
.usage-bar-fill {
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: width;
}

/* Skeleton loading animation */
@keyframes skeleton-pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.7;
    }
}

.skeleton {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.1) 0%,
            rgba(255, 255, 255, 0.2) 50%,
            rgba(255, 255, 255, 0.1) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1em;
    margin: 4px 0;
}

.skeleton-text.short {
    width: 40%;
}

.skeleton-text.medium {
    width: 60%;
}

.skeleton-text.long {
    width: 80%;
}

/* Fade in animation for loaded content */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

/* Staggered animation for lists */
.stagger-in>*:nth-child(1) {
    animation-delay: 0.05s;
}

.stagger-in>*:nth-child(2) {
    animation-delay: 0.1s;
}

.stagger-in>*:nth-child(3) {
    animation-delay: 0.15s;
}

.stagger-in>*:nth-child(4) {
    animation-delay: 0.2s;
}

.stagger-in>*:nth-child(5) {
    animation-delay: 0.25s;
}

.stagger-in>* {
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

/* Loading spinner */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* View transition system - Generic */
.view-enter {
    animation: slideFromRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.view-exit {
    animation: slideToLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

@keyframes slideFromRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideToLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

/* Specific view adjustments */
#profileView,
#pricingView,
#detailView,
#listView {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    min-height: 100vh;
    background: var(--bg-color);
}

.hidden {
    display: none !important;
}

/* Profile styles for SPA */
.profile-container {
    max-width: 600px;
    margin: 0 auto;
}

.profile-section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 1.1em;
    margin-bottom: 12px;
    opacity: 0.8;
}

/* Pricing cards in SPA */
.pricing-cards {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}

.pricing-card {
    padding: 20px;
    background: var(--card-bg);
    border-radius: 16px;
    border: var(--glass-border);
    transition: transform 0.2s;
}

.pricing-card.highlighted {
    border-color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 5%, var(--card-bg));
}


/* Touch feedback */
@media (hover: none) {

    .btn:active,
    .recording-item:active,
    .pricing-card:active {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .skeleton {
        animation: none;
        opacity: 0.5;
    }
}

/* Optimized scrolling */
.profile-container,
.pricing-screen,
#listView,
#detailView {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Input focus optimization */
input,
button,
textarea {
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
button:focus,
textarea:focus {
    outline: none;
}

/* Image optimization placeholder */
.img-placeholder {
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Content visibility for off-screen elements */
.off-screen-section {
    content-visibility: auto;
    contain-intrinsic-size: 200px;
}