/**
 * Loading States CSS
 * This file contains styles for various loading states across the application
 */

/* Button Loading State */
.btn.loading,
button.loading {
    position: relative;
    cursor: not-allowed;
    opacity: 0.8;
}

.btn.loading .spinner,
button.loading .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.btn-outline.loading .spinner,
button.btn-outline.loading .spinner {
    border: 2px solid rgba(74, 108, 247, 0.3);
    border-top-color: var(--primary-color);
}

/* Form Loading State */
.form-loading {
    position: relative;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 10;
}

.form-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 3px solid rgba(74, 108, 247, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    z-index: 11;
}

/* Page Loading State */
.page-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.page-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(74, 108, 247, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

.page-loading .loading-text {
    font-size: 1.2rem;
    color: var(--text-color-dark);
    font-weight: 500;
}

/* Section Loading State */
.section-loading {
    position: relative;
    min-height: 200px;
}

.section-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 10;
}

.section-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 3px solid rgba(74, 108, 247, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    z-index: 11;
}

/* Card Loading State */
.card-loading {
    position: relative;
    min-height: 100px;
}

.card-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 10;
    border-radius: inherit;
}

.card-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin-top: -15px;
    margin-left: -15px;
    border: 3px solid rgba(74, 108, 247, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    z-index: 11;
}

/* Table Loading State */
.table-loading {
    position: relative;
    min-height: 100px;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 10;
}

.table-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin-top: -15px;
    margin-left: -15px;
    border: 3px solid rgba(74, 108, 247, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    z-index: 11;
}

/* Modal Loading State */
.modal-loading .modal-content {
    position: relative;
}

.modal-loading .modal-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 10;
    border-radius: inherit;
}

.modal-loading .modal-content::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 3px solid rgba(74, 108, 247, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    z-index: 11;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    display: inline-block;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    width: 100%;
}

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

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

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

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-rectangle {
    width: 100%;
    height: 120px;
    border-radius: 4px;
}

.skeleton-button {
    width: 100px;
    height: 40px;
    border-radius: 4px;
}

.skeleton-card {
    padding: 20px;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.skeleton-table-row {
    display: flex;
    margin-bottom: 10px;
}

.skeleton-table-cell {
    flex: 1;
    height: 20px;
    margin-right: 10px;
}

/* Skeleton Loading for Subscription Management */
.skeleton-plan-info {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.skeleton-plan-info-item {
    display: flex;
    flex-direction: column;
}

.skeleton-info-label {
    width: 80px;
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-info-value {
    width: 120px;
    height: 20px;
}

.skeleton-plan-features {
    margin-bottom: 30px;
}

.skeleton-plan-features-header {
    width: 150px;
    height: 24px;
    margin-bottom: 15px;
}

.skeleton-plan-features-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

.skeleton-plan-feature {
    display: flex;
    align-items: center;
}

.skeleton-plan-feature-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 10px;
}

.skeleton-plan-feature-text {
    width: 180px;
    height: 16px;
}

.skeleton-plan-actions {
    display: flex;
    gap: 15px;
}

.skeleton-plan-action {
    width: 120px;
    height: 40px;
    border-radius: 5px;
}

.skeleton-usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.skeleton-usage-item {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    border-radius: 8px;
    background-color: #f9f9f9;
}

.skeleton-usage-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
}

.skeleton-usage-info {
    flex: 1;
}

.skeleton-usage-title {
    width: 120px;
    height: 20px;
    margin-bottom: 10px;
}

.skeleton-usage-stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.skeleton-usage-value {
    width: 30px;
    height: 20px;
}

.skeleton-usage-limit {
    width: 60px;
    height: 16px;
}

.skeleton-progress-bar {
    height: 6px;
    background-color: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.skeleton-plan-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.skeleton-plan-card {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
}

.skeleton-plan-card-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    background-color: #f9f9f9;
}

.skeleton-plan-badge {
    width: 80px;
    height: 24px;
    margin-bottom: 10px;
}

.skeleton-plan-price {
    margin-top: 10px;
}

.skeleton-plan-price-value {
    width: 80px;
    height: 30px;
    margin-bottom: 5px;
}

.skeleton-plan-price-period {
    width: 100px;
    height: 16px;
}

.skeleton-plan-card-features {
    padding: 20px;
}

.skeleton-plan-card-feature {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.skeleton-plan-card-feature-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 10px;
}

.skeleton-plan-card-feature-text {
    width: 180px;
    height: 16px;
}

.skeleton-plan-card-footer {
    padding: 20px;
    border-top: 1px solid #eee;
}

.skeleton-plan-card-button {
    width: 100%;
    height: 40px;
    border-radius: 5px;
}

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

.skeleton-history-table-header {
    display: flex;
    margin-bottom: 15px;
}

.skeleton-history-table-header-cell {
    flex: 1;
    height: 20px;
    margin-right: 10px;
}

.skeleton-history-table-row {
    display: flex;
    margin-bottom: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.skeleton-history-table-cell {
    flex: 1;
    height: 20px;
    margin-right: 10px;
}

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

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

/* Responsive Styles */
@media (max-width: 768px) {
    .skeleton-plan-info {
        grid-template-columns: 1fr;
    }
    
    .skeleton-plan-features-list {
        grid-template-columns: 1fr;
    }
    
    .skeleton-plan-actions {
        flex-direction: column;
    }
    
    .skeleton-usage-grid {
        grid-template-columns: 1fr;
    }
    
    .skeleton-plan-cards {
        grid-template-columns: 1fr;
    }
    
    .skeleton-history-table-header-cell:nth-child(n+4),
    .skeleton-history-table-cell:nth-child(n+4) {
        display: none;
    }
}
