/**
 * OyoClean App - Modern UX Styles
 * Smooth animations and transitions for a high-tech app experience
 */

/* ============================================
   CSS VARIABLES - Design Tokens
   ============================================ */
:root {
    --oc-primary: #10b981;
    --oc-primary-dark: #059669;
    --oc-primary-light: #34d399;
    --oc-accent: #facc15;
    --oc-danger: #dc2626;
    --oc-warning: #f59e0b;
    --oc-success: #10b981;
    --oc-info: #3b82f6;
    --oc-surface: #ffffff;
    --oc-surface-alt: #f8fafc;
    --oc-border: #e5e7eb;
    --oc-text: #1e293b;
    --oc-text-muted: #64748b;
    --oc-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --oc-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --oc-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
    --oc-shadow-xl: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
    --oc-radius: 12px;
    --oc-radius-lg: 16px;
    --oc-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --oc-transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */
body {
    opacity: 1;
    transition: opacity 0.3s ease;
}

body.page-transitioning {
    opacity: 0;
}

body.page-transitioning {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    pointer-events: none;
}

@media (max-width: 480px) {
    #toast-container {
        top: auto;
        bottom: 20px;
        left: 16px;
        right: 16px;
    }
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--oc-surface);
    border-radius: var(--oc-radius);
    box-shadow: var(--oc-shadow-lg);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55),
                opacity 0.3s ease;
    pointer-events: auto;
    max-width: 400px;
    border-left: 4px solid var(--oc-info);
}

.toast--visible {
    transform: translateX(0);
    opacity: 1;
}

.toast--hiding {
    transform: translateX(120%);
    opacity: 0;
}

.toast--success {
    border-left-color: var(--oc-success);
}

.toast--success .toast__icon {
    color: var(--oc-success);
}

.toast--error {
    border-left-color: var(--oc-danger);
}

.toast--error .toast__icon {
    color: var(--oc-danger);
}

.toast--warning {
    border-left-color: var(--oc-warning);
}

.toast--warning .toast__icon {
    color: var(--oc-warning);
}

.toast--info {
    border-left-color: var(--oc-info);
}

.toast--info .toast__icon {
    color: var(--oc-info);
}

.toast__icon {
    font-size: 1.3em;
    font-weight: bold;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: currentColor;
    color: white;
}

.toast__icon::before {
    content: '';
}

.toast--success .toast__icon,
.toast--error .toast__icon,
.toast--warning .toast__icon,
.toast--info .toast__icon {
    background: currentColor;
}

.toast__icon {
    background: transparent !important;
}

.toast__message {
    flex: 1;
    font-size: 0.95rem;
    color: var(--oc-text);
    line-height: 1.4;
}

.toast__close {
    background: none;
    border: none;
    font-size: 1.5em;
    color: var(--oc-text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
}

.toast__close:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#loading-overlay.loading-overlay--visible {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    text-align: center;
    animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.loading-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid var(--oc-border);
    border-top-color: var(--oc-primary);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

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

.loading-message {
    color: var(--oc-text);
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}

body.loading-active {
    overflow: hidden;
}

/* ============================================
   SKELETON LOADING
   ============================================ */
.skeleton-card {
    background: var(--oc-surface);
    border-radius: var(--oc-radius-lg);
    overflow: hidden;
    box-shadow: var(--oc-shadow);
}

.skeleton-card--hidden {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s, transform 0.3s;
}

.skeleton-image {
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-content {
    padding: 20px;
}

.skeleton-title {
    height: 24px;
    width: 70%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    margin-bottom: 12px;
}

.skeleton-text {
    height: 16px;
    width: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

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

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

/* ============================================
   PULL TO REFRESH
   ============================================ */
#pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    background: linear-gradient(135deg, var(--oc-primary) 0%, var(--oc-primary-light) 100%);
    overflow: hidden;
    z-index: 9999;
    transition: height 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ptr-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: white;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s, transform 0.3s;
}

#pull-to-refresh.ptr--pulling .ptr-content {
    opacity: 1;
    transform: translateY(0);
}

.ptr-icon {
    font-size: 1.5rem;
    transition: transform 0.3s;
}

#pull-to-refresh.ptr--ready .ptr-icon {
    transform: rotate(180deg);
}

.ptr-text {
    font-size: 0.9rem;
    font-weight: 500;
}

.ptr-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   BUTTON ENHANCEMENTS
   ============================================ */
.btn, .submit-button, button {
    position: relative;
    overflow: hidden;
}

.btn--loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============================================
   SCROLL ANIMATIONS
   ============================================ */
.project-card,
.step,
.feature,
.testimonial,
.donor-card,
.stat,
.hero__stat {
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

/* Disable animation classes that would hide content */
.project-card.animate-ready,
.step.animate-ready,
.feature.animate-ready,
.testimonial.animate-ready,
.donor-card.animate-ready,
.stat.animate-ready,
.hero__stat.animate-ready,
.project-card.animate-in,
.step.animate-in,
.feature.animate-in,
.testimonial.animate-in,
.donor-card.animate-in,
.stat.animate-in,
.hero__stat.animate-in {
    opacity: 1 !important;
    transform: translateY(0) !important;
    visibility: visible !important;
}

/* Staggered animation delays */
.project-card:nth-child(1) { transition-delay: 0s; }
.project-card:nth-child(2) { transition-delay: 0.1s; }
.project-card:nth-child(3) { transition-delay: 0.2s; }
.project-card:nth-child(4) { transition-delay: 0.3s; }
.project-card:nth-child(5) { transition-delay: 0.4s; }
.project-card:nth-child(6) { transition-delay: 0.5s; }

/* ============================================
   IMAGE LIGHTBOX
   ============================================ */
#lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
    pointer-events: none; /* Allow clicks to pass through when closed/closing */
}

#lightbox-overlay.lightbox--visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Capture clicks only when fully visible */
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 10001;
    opacity: 1;
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
    min-width: 100px;
    min-height: 50px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.lightbox-close:hover,
.lightbox-close:active {
    opacity: 1;
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--oc-radius);
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55),
                opacity 0.3s ease;
}

#lightbox-overlay.lightbox--visible .lightbox-image {
    transform: scale(1);
    opacity: 1;
}

/* ============================================
   SCROLL TO TOP BUTTON
   ============================================ */
#scroll-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--oc-primary);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.3s;
    box-shadow: var(--oc-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

#scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

#scroll-to-top:hover {
    background: var(--oc-primary-dark);
    transform: translateY(-3px) scale(1.05);
}

#scroll-to-top:active {
    transform: translateY(0) scale(0.95);
}

@media (max-width: 768px) {
    #scroll-to-top {
        bottom: 80px;
        right: 16px;
        width: 44px;
        height: 44px;
    }
}

/* ============================================
   SCROLL TO BOTTOM BUTTON
   ============================================ */
#scroll-to-bottom {
    position: fixed;
    bottom: 24px;
    right: 84px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--oc-primary);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.8);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.3s;
    box-shadow: var(--oc-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

#scroll-to-bottom.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

#scroll-to-bottom:hover {
    background: var(--oc-primary-dark);
    transform: translateY(-3px) scale(1.05);
}

#scroll-to-bottom:active {
    transform: translateY(0) scale(0.95);
}

@media (max-width: 768px) {
    #scroll-to-bottom {
        bottom: 80px;
        right: 70px;
        width: 44px;
        height: 44px;
    }
}

/* ============================================
   FORM FLOATING LABELS
   ============================================ */
.form-group {
    position: relative;
}

.form-group.is-focused label {
    color: var(--oc-primary);
}

.form-group.is-focused input,
.form-group.is-focused textarea {
    border-color: var(--oc-primary);
    box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.1);
}

/* ============================================
   OFFLINE INDICATOR
   ============================================ */
body.is-offline::before {
    content: '📡 Vous êtes hors ligne';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--oc-warning);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10003;
}

body.is-offline .header {
    margin-top: 36px;
}

/* ============================================
   ENHANCED PROJECT CARD HOVER
   ============================================ */
.project-card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--oc-shadow-xl);
}

.project-card:active {
    transform: translateY(-4px) scale(0.98);
}

.project-card__media img {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-card:hover .project-card__media img {
    transform: scale(1.08);
}

/* ============================================
   ENHANCED BUTTON STYLES
   ============================================ */
.btn,
.submit-button,
.header__btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover,
.submit-button:hover,
.header__btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--oc-shadow-lg);
}

.btn:active,
.submit-button:active,
.header__btn:active {
    transform: translateY(0);
}

/* ============================================
   SELECTION HUD ENHANCEMENT
   ============================================ */
.selection-hud {
    animation: slideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   IMAGE LAZY LOADING
   ============================================ */
img {
    opacity: 1;
    transition: opacity 0.5s ease;
}

img.lazy-loading {
    opacity: 0;
}

img.loaded {
    opacity: 1;
}

/* ============================================
   MOBILE MENU ANIMATION
   ============================================ */
.mobile-menu {
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-menu.active {
    transform: translateX(0);
}

.mobile-menu__nav {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transition-delay: 0.1s;
}

.mobile-menu.active .mobile-menu__nav {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   HERO SECTION ENHANCEMENTS
   ============================================ */
.hero__content {
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero__stat {
    animation: fadeInUp 0.6s ease-out backwards;
}

.hero__stat:nth-child(1) { animation-delay: 0.2s; }
.hero__stat:nth-child(2) { animation-delay: 0.3s; }
.hero__stat:nth-child(3) { animation-delay: 0.4s; }
.hero__stat:nth-child(4) { animation-delay: 0.5s; }
.hero__stat:nth-child(5) { animation-delay: 0.6s; }
.hero__stat:nth-child(6) { animation-delay: 0.7s; }

/* ============================================
   DONATION FORM ENHANCEMENTS
   ============================================ */
.donation-form {
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.payment-option {
    transition: all 0.3s ease;
}

.payment-option:hover {
    transform: translateX(5px);
    background: #f8fafc;
}

/* ============================================
   CERTIFICATE PREVIEW ENHANCEMENT
   ============================================ */
.certificate-preview {
    animation: shimmerBorder 3s ease-in-out infinite;
}

@keyframes shimmerBorder {
    0%, 100% {
        box-shadow: 0 0 20px rgba(191, 161, 0, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(191, 161, 0, 0.4);
    }
}

/* ============================================
   REDUCED MOTION SUPPORT
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .project-card,
    .step,
    .feature,
    .testimonial,
    .donor-card,
    .stat {
        opacity: 1;
        transform: none;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    #toast-container,
    #loading-overlay,
    #pull-to-refresh,
    #scroll-to-top,
    #lightbox-overlay,
    .selection-hud,
    .mobile-menu {
        display: none !important;
    }
    
    body {
        opacity: 1 !important;
    }
}
