/**
 * CGPSCedu — Additional Utilities & Enhancements
 * Responsive helpers, animations, and performance optimizations
 */

/* ═══════════════════════════════════════════
   RESPONSIVE UTILITIES
═══════════════════════════════════════════ */

/* Container Queries Support */
@container (min-width: 640px) {
    .modern-course-card {
        grid-column: span 1;
    }
}

/* Aspect Ratio Utilities */
.aspect-video {
    aspect-ratio: 16 / 9;
}

.aspect-square {
    aspect-ratio: 1 / 1;
}

.aspect-card {
    aspect-ratio: 4 / 3;
}

/* ═══════════════════════════════════════════
   LOADING STATES & SKELETONS
═══════════════════════════════════════════ */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

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

.skeleton-card {
    height: 400px;
    width: 100%;
}

.skeleton-text {
    height: 1rem;
    width: 100%;
    margin-bottom: 0.5rem;
}

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

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

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,215,0,0.2);
    border-top-color: #FFD700;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,26,46,0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-content .loading-spinner {
    width: 48px;
    height: 48px;
    border-width: 4px;
    margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: 5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    min-width: 300px;
    max-width: 400px;
    padding: 1rem 1.25rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: all;
    transform: translateX(120%);
    animation: slideInToast 0.3s ease forwards;
}

.toast.removing {
    animation: slideOutToast 0.3s ease forwards;
}

@keyframes slideInToast {
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutToast {
    to {
        transform: translateX(120%);
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: 0.875rem;
    color: #6c757d;
}

.toast-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 8px;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toast-close:hover {
    background: #e9ecef;
    color: #1a1a2e;
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

.toast.info {
    border-left: 4px solid #3b82f6;
}

/* ═══════════════════════════════════════════
   MODAL / POPUP ENHANCEMENTS
═══════════════════════════════════════════ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26,26,46,0.7);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-backdrop.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
}

.modal-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 10px;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #e9ecef;
    color: #1a1a2e;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ═══════════════════════════════════════════
   FORM ENHANCEMENTS
═══════════════════════════════════════════ */

.modern-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.modern-input:focus {
    outline: none;
    background: white;
    border-color: #FFD700;
    box-shadow: 0 0 0 4px rgba(255,215,0,0.1);
}

.modern-input::placeholder {
    color: #9ca3af;
}

.modern-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-family: inherit;
    min-height: 120px;
    resize: vertical;
    transition: all 0.2s ease;
}

.modern-textarea:focus {
    outline: none;
    background: white;
    border-color: #FFD700;
    box-shadow: 0 0 0 4px rgba(255,215,0,0.1);
}

.modern-select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modern-select:focus {
    outline: none;
    background: white;
    border-color: #FFD700;
    box-shadow: 0 0 0 4px rgba(255,215,0,0.1);
}

.modern-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.modern-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    cursor: pointer;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.form-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.375rem;
}

.form-helper {
    color: #6c757d;
    font-size: 0.875rem;
    margin-top: 0.375rem;
}

/* ═══════════════════════════════════════════
   BADGE COMPONENTS
═══════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: rgba(255,215,0,0.15);
    color: #E6C200;
    border: 1px solid rgba(255,215,0,0.3);
}

.badge-success {
    background: rgba(16,185,129,0.15);
    color: #059669;
    border: 1px solid rgba(16,185,129,0.3);
}

.badge-error {
    background: rgba(239,68,68,0.15);
    color: #dc2626;
    border: 1px solid rgba(239,68,68,0.3);
}

.badge-warning {
    background: rgba(245,158,11,0.15);
    color: #d97706;
    border: 1px solid rgba(245,158,11,0.3);
}

.badge-info {
    background: rgba(59,130,246,0.15);
    color: #2563eb;
    border: 1px solid rgba(59,130,246,0.3);
}

/* ═══════════════════════════════════════════
   BUTTON ENHANCEMENTS
═══════════════════════════════════════════ */

.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    font-weight: 700;
    font-size: 0.9375rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn-modern:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-modern-primary {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #1a1a2e;
    box-shadow: 0 4px 12px rgba(255,215,0,0.25);
}

.btn-modern-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255,215,0,0.35);
}

.btn-modern-secondary {
    background: #1a1a2e;
    color: white;
}

.btn-modern-secondary:hover:not(:disabled) {
    background: #262640;
    transform: translateY(-2px);
}

.btn-modern-outline {
    background: transparent;
    border: 2px solid #e9ecef;
    color: #1a1a2e;
}

.btn-modern-outline:hover:not(:disabled) {
    background: #f8f9fa;
    border-color: #1a1a2e;
}

.btn-modern-ghost {
    background: transparent;
    color: #1a1a2e;
}

.btn-modern-ghost:hover:not(:disabled) {
    background: #f8f9fa;
}

.btn-modern.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn-modern.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ═══════════════════════════════════════════
   CARD HOVER EFFECTS
═══════════════════════════════════════════ */

.card-hover-lift {
    transition: all 0.3s ease;
}

.card-hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

.card-hover-glow {
    position: relative;
    transition: all 0.3s ease;
}

.card-hover-glow::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-radius: inherit;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.card-hover-glow:hover::before {
    opacity: 0.2;
}

/* ═══════════════════════════════════════════
   PROGRESS BARS
═══════════════════════════════════════════ */

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #FFD700 0%, #FFA500 100%);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.progress-animated {
    position: relative;
    overflow: hidden;
}

.progress-animated::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    to {
        left: 100%;
    }
}

/* ═══════════════════════════════════════════
   TOOLTIPS
═══════════════════════════════════════════ */

.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip-text {
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: #1a1a2e;
    color: white;
    font-size: 0.875rem;
    border-radius: 8px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1a1a2e;
}

.tooltip-container:hover .tooltip-text {
    opacity: 1;
}

/* ═══════════════════════════════════════════
   ACCORDION COMPONENT
═══════════════════════════════════════════ */

.accordion-item {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.accordion-header {
    padding: 1.25rem;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s ease;
}

.accordion-header:hover {
    background: #f8f9fa;
}

.accordion-title {
    font-weight: 700;
    color: #1a1a2e;
}

.accordion-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-item.active .accordion-content {
    max-height: 1000px;
}

.accordion-body {
    padding: 0 1.25rem 1.25rem;
    color: #6c757d;
    line-height: 1.7;
}

/* ═══════════════════════════════════════════
   MOBILE OPTIMIZATIONS
═══════════════════════════════════════════ */

@media (max-width: 768px) {
    .toast-container {
        right: 1rem;
        left: 1rem;
    }
    
    .toast {
        min-width: auto;
        max-width: 100%;
    }
    
    .modal-backdrop {
        padding: 0;
    }
    
    .modal-content {
        border-radius: 16px 16px 0 0;
        max-height: 95vh;
        align-self: flex-end;
        width: 100%;
    }
}

/* ═══════════════════════════════════════════
   PERFORMANCE OPTIMIZATIONS
═══════════════════════════════════════════ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* GPU acceleration for smooth animations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Prevent layout shift */
.prevent-shift {
    content-visibility: auto;
}

/* ═══════════════════════════════════════════
   PRINT STYLES
═══════════════════════════════════════════ */

@media print {
    .modern-header,
    .modern-footer,
    .mobile-nav-overlay,
    .scroll-to-top,
    .toast-container,
    .category-nav-section {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.875em;
        color: #6c757d;
    }
}
