/**
 * Urban Formation PDF Viewer - Frontend Styles
 * Version: 1.0.0
 */

/* ========================================
   BOUTONS
======================================== */

/* Bouton Voir détails */
.ufpv-view-pdf-btn {
    display: inline-block;
    width: 100%;
    margin-top: 8px;
    padding: 12px 24px;
    background-color: var(--ufpv-button-color, #0073aa);
    color: #ffffff !important;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
}

.ufpv-view-pdf-btn:hover,
.ufpv-view-pdf-btn:focus {
    background-color: var(--ufpv-button-hover-color, #005a87);
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.ufpv-view-pdf-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* État de chargement pour les boutons */
.button.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.button.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: ufpvButtonSpin 0.6s linear infinite;
}

/* Bouton après ajout au panier */
.button.added {
    background-color: #46b450 !important;
}

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

/* Bouton sur page produit unique */
.ufpv-single-product.ufpv-view-pdf-btn {
    margin-top: 15px;
    width: auto;
    min-width: 200px;
}

/* Ajustement du bouton Ajouter au panier */
.woocommerce ul.products li.product .button.add_to_cart_button,
.woocommerce-page ul.products li.product .button.add_to_cart_button {
    width: 100%;
    margin-bottom: 5px;
}


/* ========================================
   MODALE PDF
======================================== */

/* Overlay de la modale */
.ufpv-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 999999;
    overflow: auto;
    animation: ufpvFadeIn 0.3s ease;
}

.ufpv-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Container de la modale */
.ufpv-modal-container {
    background: #ffffff;
    border-radius: 8px;
    max-width: 1400px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: ufpvSlideIn 0.3s ease;
}

/* Header de la modale */
.ufpv-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid #e5e5e5;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.ufpv-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

/* Bouton fermer */
.ufpv-modal-close {
    background: transparent;
    border: none;
    font-size: 32px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.ufpv-modal-close:hover {
    background-color: #e5e5e5;
    color: #333;
}

/* Body de la modale */
.ufpv-modal-body {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 400px;
}

/* Loader */
.ufpv-pdf-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1;
}

.ufpv-pdf-loader.hidden {
    display: none;
}

.ufpv-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: ufpvSpin 1s linear infinite;
    margin: 0 auto 15px;
}

.ufpv-pdf-loader p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

/* Viewer PDF */
.ufpv-pdf-viewer {
    width: 100%;
    height: 70vh;
    border: none;
    display: block;
    background: #f5f5f5;
}

/* Contrôles PDF personnalisés */
.ufpv-pdf-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: #2c3e50;
    border-bottom: 1px solid #34495e;
    flex-wrap: wrap;
}

.ufpv-pdf-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
    min-width: 40px;
}

.ufpv-pdf-btn:hover {
    background: #2980b9;
}

.ufpv-pdf-btn:disabled {
    background: #7f8c8d;
    cursor: not-allowed;
    opacity: 0.6;
}

.ufpv-pdf-page-info,
.ufpv-pdf-zoom-level {
    color: white;
    font-size: 14px;
    font-weight: 500;
    padding: 0 10px;
    white-space: nowrap;
}

.ufpv-pdf-separator {
    color: #7f8c8d;
    font-size: 18px;
    padding: 0 5px;
    display: inline-block;
}

/* Responsive Mobile */
@media (max-width: 768px) {
    .ufpv-pdf-controls {
        padding: 10px 5px;
        gap: 5px;
    }
    
    .ufpv-pdf-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 35px;
    }
    
    .ufpv-pdf-page-info,
    .ufpv-pdf-zoom-level {
        font-size: 12px;
        padding: 0 5px;
    }
    
    .ufpv-pdf-separator {
        display: none;
    }
}

@media (max-width: 480px) {
    .ufpv-pdf-controls {
        gap: 3px;
        padding: 8px 3px;
    }
    
    .ufpv-pdf-btn {
        padding: 5px 10px;
        font-size: 11px;
        min-width: 30px;
    }
    
    .ufpv-pdf-page-info,
    .ufpv-pdf-zoom-level {
        font-size: 11px;
        padding: 0 3px;
    }
}

/* Container du canvas */
.ufpv-pdf-canvas-container {
    width: 100%;
    height: calc(70vh - 60px);
    overflow: auto;
    background: #525659;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

#ufpv-pdf-canvas {
    display: block;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    background: white;
}

/* Responsive Mobile - Canvas Container */
@media (max-width: 768px) {
    .ufpv-pdf-canvas-container {
        height: calc(80vh - 50px);
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .ufpv-pdf-canvas-container {
        height: calc(85vh - 50px);
        padding: 5px;
    }
}

/* Masquer le bouton de téléchargement du PDF */
.ufpv-pdf-viewer::-webkit-media-controls-download-button {
    display: none !important;
}

.ufpv-pdf-viewer::-webkit-media-controls-enclosure {
    overflow: hidden;
}

.ufpv-pdf-viewer::--webkit-media-controls-panel {
    display: none !important;
}

/* Protection du PDF */
.ufpv-pdf-viewer.ufpv-protected {
    pointer-events: all;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Overlay de protection pour bloquer les interactions */
.ufpv-pdf-protection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: transparent;
}

/* Protection contre les captures d'écran */
.ufpv-modal-body {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Désactiver le filtre qui pourrait aider les captures */
@media print {
    .ufpv-modal-overlay {
        display: none !important;
    }
}


/* ========================================
   GRILLE DE FORMATIONS (SHORTCODE)
======================================== */

.ufpv-formations-grid {
    display: grid;
    gap: 30px;
    margin: 30px 0;
}

/* Colonnes responsive */
.ufpv-formations-grid.ufpv-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.ufpv-formations-grid.ufpv-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.ufpv-formations-grid.ufpv-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Carte de formation */
.ufpv-formation-card {
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ufpv-formation-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-5px);
}

/* Image de la formation */
.ufpv-formation-image {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.ufpv-formation-image a {
    display: block;
    line-height: 0;
}

.ufpv-formation-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.ufpv-formation-card:hover .ufpv-formation-image img {
    transform: scale(1.05);
}

/* Contenu de la formation */
.ufpv-formation-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Titre */
.ufpv-formation-title {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
}

.ufpv-formation-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.ufpv-formation-title a:hover {
    color: #0073aa;
}

/* Extrait */
.ufpv-formation-excerpt {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    flex: 1;
}

/* Prix */
.ufpv-formation-price {
    margin: 0 0 15px 0;
    font-size: 20px;
    font-weight: 700;
    color: #0073aa;
}

.ufpv-formation-price del {
    color: #999;
    font-size: 16px;
    margin-right: 8px;
}

.ufpv-formation-price ins {
    text-decoration: none;
}

/* Boutons */
.ufpv-formation-buttons {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.ufpv-formation-buttons .button {
    flex: 1;
    text-align: center;
    padding: 12px 20px;
    margin: 0;
    white-space: nowrap;
}


/* ========================================
   ANIMATIONS
======================================== */

@keyframes ufpvFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes ufpvSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes ufpvSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}


/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 1024px) {
    .ufpv-formations-grid.ufpv-columns-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .ufpv-formations-grid.ufpv-columns-3,
    .ufpv-formations-grid.ufpv-columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ufpv-modal-container {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    .ufpv-modal-header {
        padding: 15px 20px;
    }
    
    .ufpv-modal-header h3 {
        font-size: 18px;
    }
    
    .ufpv-modal-body {
        height: calc(100vh - 60px) !important;
    }
    
    .ufpv-pdf-viewer {
        height: 100% !important;
    }
}

@media (max-width: 480px) {
    .ufpv-formations-grid.ufpv-columns-2,
    .ufpv-formations-grid.ufpv-columns-3,
    .ufpv-formations-grid.ufpv-columns-4 {
        grid-template-columns: 1fr;
    }
    
    .ufpv-formation-content {
        padding: 15px;
    }
    
    .ufpv-view-pdf-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    /* Empiler les boutons verticalement sur mobile */
    .ufpv-formation-buttons {
        flex-direction: column;
    }
    
    .ufpv-formation-buttons .button {
        width: 100%;
    }
}


/* ========================================
   COMPATIBILITÉ THÈMES
======================================== */

/* Reset des styles WooCommerce qui pourraient interférer */
.woocommerce ul.products li.product .ufpv-view-pdf-btn,
.woocommerce-page ul.products li.product .ufpv-view-pdf-btn {
    margin: 8px 0 0 0;
    width: 100%;
}

/* Elementor */
.elementor-widget-wc-products .ufpv-view-pdf-btn {
    width: 100%;
    margin-top: 8px;
}

/* Désactiver le clic droit sur le PDF en mode protégé */
.ufpv-protected {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Spinner inline pour le bouton Souscrire */
.ufpv-spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: ufpv-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 5px;
}

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

/* Bouton "Voir souscription" */
.ufpv-in-cart {
    background-color: #46a049 !important;
    border-color: #46a049 !important;
    cursor: pointer !important;
}

.ufpv-in-cart:hover {
    background-color: #3d8b40 !important;
    border-color: #3d8b40 !important;
}

/* État loading du bouton */
.single_add_to_cart_button.loading,
.add_to_cart_button.loading {
    opacity: 0.7;
    cursor: wait !important;
}

/* ============================================
   GRILLE DE FORMATIONS - BELLE PRÉSENTATION
   ============================================ */

.urban-formations-grid {
    display: grid;
    gap: 30px;
    margin: 40px 0;
    padding: 0;
}

/* 3 colonnes par défaut */
.urban-formations-grid.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* 4 colonnes */
.urban-formations-grid.columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* 2 colonnes (si besoin) */
.urban-formations-grid.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* Responsive Tablette */
@media (max-width: 1024px) {
    .urban-formations-grid.columns-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .urban-formations-grid.columns-3,
    .urban-formations-grid.columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .urban-formations-grid {
        gap: 20px;
    }
}

/* Responsive Mobile */
@media (max-width: 480px) {
    .urban-formations-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* Carte de formation */
.formation-item {
    position: relative;
}

.formation-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.formation-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* Image de la formation */
.formation-image {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: #f5f5f5;
}

.formation-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.formation-card:hover .formation-image img {
    transform: scale(1.05);
}

/* Contenu de la carte */
.formation-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Titre de la formation */
.formation-title {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 12px 0;
    line-height: 1.4;
    min-height: 56px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Description */
.formation-description {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 16px;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 63px;
}

/* Prix */
.formation-price {
    font-size: 24px;
    font-weight: 700;
    color: #e74c3c;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.formation-price .woocommerce-Price-amount {
    color: #e74c3c;
}

/* Actions (boutons) */
.formation-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: auto;
}

.formation-actions .button,
.formation-actions .added_to_cart {
    flex: 1;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    border-radius: 6px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

/* Bouton Souscrire */
.formation-actions .button.product_type_simple,
.formation-actions .single_add_to_cart_button {
    background: #3498db;
    color: white !important;
}

.formation-actions .button.product_type_simple:hover,
.formation-actions .single_add_to_cart_button:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

/* Bouton Mes souscriptions (notre bouton custom) */
.formation-actions .ufpv-custom-cart-btn {
    background: #27ae60 !important;
    color: white !important;
    flex: 1;
}

.formation-actions .ufpv-custom-cart-btn:hover {
    background: #229954 !important;
    transform: translateY(-2px);
}

/* Masquer TOUS les boutons WooCommerce quand notre bouton custom existe */
.formation-actions.ufpv-has-custom-btn form.cart,
.formation-actions.ufpv-has-custom-btn .add_to_cart_button:not(.ufpv-custom-cart-btn),
.formation-actions.ufpv-has-custom-btn .single_add_to_cart_button,
.formation-actions.ufpv-has-custom-btn .added_to_cart:not(.ufpv-custom-cart-btn),
.formation-actions.ufpv-has-custom-btn .ajax_add_to_cart:not(.ufpv-custom-cart-btn) {
    display: none !important;
}

/* Bouton Voir détails */
.formation-actions .ufpv-view-pdf-btn {
    background: #95a5a6;
    color: white !important;
}

.formation-actions .ufpv-view-pdf-btn:hover {
    background: #7f8c8d;
}

/* Badge "Nouveau" ou autres badges */
.formation-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #e74c3c;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 10;
}

/* Animation de chargement */
.formation-card.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* État vide */
.urban-formations-grid:empty::after {
    content: "Aucune formation disponible";
    display: block;
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* Responsive Mobile - Ajustements */
@media (max-width: 480px) {
    .formation-image {
        height: 180px;
    }
    
    .formation-content {
        padding: 16px;
    }
    
    .formation-title {
        font-size: 18px;
        min-height: auto;
    }
    
    .formation-description {
        font-size: 13px;
        min-height: auto;
    }
    
    .formation-price {
        font-size: 20px;
    }
    
    .formation-actions {
        flex-direction: column;
    }
    
    .formation-actions .button {
        padding: 10px 16px;
        font-size: 14px;
        width: 100%;
    }
}
