/**
 * Premium PDF Embedding - Public Styles
 */

/* Sidebar PDF - Layout Elegante */
.ppdf-emb-sidebar {
    margin: 40px 0;
    padding: 0;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
}

.ppdf-emb-sidebar-inner {
    padding: 0;
}

.ppdf-emb-sidebar-header {
    background: #d63638; /* Sovrascritto dinamicamente con inline style */
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.ppdf-emb-sidebar-title {
    margin: 0;
    font-size: 1.3em !important;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
}

.ppdf-emb-sidebar-title svg {
    fill: #ffffff;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.ppdf-emb-sidebar-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.ppdf-emb-sidebar-badge svg {
    fill: #ffffff;
}

.ppdf-emb-sidebar-notice {
    padding: 15px 25px;
    background: #fff3cd;
    border-bottom: 1px solid #ffc107;
    color: #856404;
    font-size: 14px;
}

.ppdf-emb-sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ppdf-emb-sidebar-item {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #e9ecef;
}

.ppdf-emb-sidebar-item:last-child {
    border-bottom: none;
}

.ppdf-emb-sidebar-button {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px 25px;
    width: 100%;
    background: #ffffff;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-family: inherit;
}

.ppdf-emb-sidebar-button:hover {
    background: #f8f9fa;
    padding-left: 30px;
}

.ppdf-emb-sidebar-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: #fee;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.ppdf-emb-sidebar-button:hover .ppdf-emb-sidebar-icon {
    background: #d63638;
}

.ppdf-emb-sidebar-icon svg {
    width: 30px;
    height: 30px;
    fill: #d63638;
    transition: fill 0.3s ease;
}

.ppdf-emb-sidebar-button:hover .ppdf-emb-sidebar-icon svg {
    fill: #ffffff;
}

.ppdf-emb-sidebar-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.ppdf-emb-sidebar-filename {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.ppdf-emb-sidebar-meta {
    font-size: 13px;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ppdf-emb-sidebar-badge-small {
    display: inline-flex;
    align-items: center;
    opacity: 0.7;
}

.ppdf-emb-sidebar-badge-small svg {
    fill: #6c757d;
}

.ppdf-emb-sidebar-arrow {
    flex-shrink: 0;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.ppdf-emb-sidebar-button:hover .ppdf-emb-sidebar-arrow {
    opacity: 1;
    transform: translateX(5px);
}

.ppdf-emb-sidebar-arrow svg {
    fill: #6c757d;
}

/* Lista PDF Legacy (mantieni per shortcode) */
.ppdf-emb-list-wrapper {
    margin: 2em 0;
}

.ppdf-emb-notice {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    border-left: 4px solid;
}

.ppdf-emb-notice-warning {
    background-color: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.ppdf-emb-notice p {
    margin: 0;
    font-size: 14px;
}

.ppdf-emb-pdf-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 15px;
}

.ppdf-emb-pdf-item {
    margin: 0;
    padding: 0;
}

.ppdf-emb-pdf-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.ppdf-emb-pdf-link:hover {
    border-color: #d63638;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.ppdf-emb-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #d63638 0%, #b32d2e 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ppdf-emb-icon svg {
    fill: #ffffff;
}

.ppdf-emb-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.ppdf-emb-filename {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ppdf-emb-filesize {
    font-size: 14px;
    color: #666666;
}

.ppdf-emb-lock {
    flex-shrink: 0;
    opacity: 0.6;
}

.ppdf-emb-lock svg {
    fill: #666666;
}

/* Modals Base */
.ppdf-emb-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999999 !important; /* Aumentato per essere sopra tutto, anche header Avada */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ppdf-emb-modal.ppdf-emb-active {
    opacity: 1;
    visibility: visible;
}

.ppdf-emb-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    cursor: pointer;
    z-index: 1;
}

.ppdf-emb-modal-content {
    position: relative;
    z-index: 10 !important; /* Sopra al backdrop */
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
}

.ppdf-emb-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 1 !important; /* Abbassato per non coprire i controlli PDF */
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

/* X più piccola e spostata per il modal PDF */
.ppdf-emb-pdf-modal .ppdf-emb-modal-close {
    top: 60px; /* Spostata sotto la toolbar del PDF */
    right: 20px; /* Distanza maggiore dal bordo destro */
    width: 32px;
    height: 32px;
}

.ppdf-emb-pdf-modal .ppdf-emb-modal-close svg {
    width: 18px;
    height: 18px;
}

.ppdf-emb-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: rotate(90deg);
}

.ppdf-emb-modal-close svg {
    fill: #ffffff;
}

.ppdf-emb-modal-body {
    padding: 40px 30px 30px;
}

.ppdf-emb-modal-body h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
    color: #1a1a1a;
}

/* Form Password */
.ppdf-emb-form-group {
    margin-bottom: 15px;
}

.ppdf-emb-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.ppdf-emb-input:focus {
    outline: none;
    border-color: #d63638;
}

.ppdf-emb-input-error {
    border-color: #dc3232;
}

.ppdf-emb-error {
    padding: 10px 15px;
    margin-bottom: 15px;
    background: #fdecea;
    border: 1px solid #dc3232;
    border-radius: 4px;
    color: #dc3232;
    font-size: 14px;
}

.ppdf-emb-btn {
    width: 100%;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.ppdf-emb-btn-primary {
    background: linear-gradient(135deg, #d63638 0%, #b32d2e 100%);
    color: #ffffff;
}

.ppdf-emb-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(214, 54, 56, 0.3);
}

.ppdf-emb-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ppdf-emb-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: ppdf-emb-spin 0.8s linear infinite;
}

@keyframes ppdf-emb-spin {
    to { transform: rotate(360deg); }
}

/* Modal PDF */
.ppdf-emb-pdf-modal .ppdf-emb-modal-content {
    max-width: 95vw;
    width: 1200px;
    max-height: 95vh;
    height: 90vh; /* Aggiungo altezza esplicita per il flex */
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 10 !important; /* Stesso z-index del modal normale */
}

.ppdf-emb-pdf-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
    height: 100%; /* Assicura che prenda tutta l'altezza disponibile */
}

.ppdf-emb-pdf-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff; /* Sfondo bianco per vedere se l'iframe c'è */
}

/* Blocca scroll quando modal attivo */
body.ppdf-emb-no-scroll {
    overflow: hidden;
}

/* Responsive - Breakpoint Avada dinamici */
/* Desktop Large - Default */
@media (min-width: 1200px) {
    .ppdf-emb-pdf-list {
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    }
}

/* Desktop */
@media (min-width: 1025px) and (max-width: 1199px) {
    .ppdf-emb-pdf-list {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
}

/* Tablet Medium */
@media (min-width: 768px) and (max-width: 1024px) {
    .ppdf-emb-pdf-list {
        grid-template-columns: 1fr;
    }
    
    .ppdf-emb-sidebar-header {
        padding: 18px 20px;
    }
    
    .ppdf-emb-sidebar-button {
        padding: 18px 20px;
    }
    
    .ppdf-emb-modal-content {
        width: 95%;
    }
    
    .ppdf-emb-pdf-modal .ppdf-emb-modal-content {
        width: 95vw;
        max-width: 95vw;
    }
}

/* Tablet Small */
@media (min-width: 641px) and (max-width: 767px) {
    .ppdf-emb-pdf-list {
        grid-template-columns: 1fr;
    }
    
    .ppdf-emb-pdf-link {
        padding: 15px;
        gap: 12px;
    }
    
    .ppdf-emb-icon {
        width: 40px;
        height: 40px;
    }
    
    .ppdf-emb-filename {
        font-size: 15px;
    }
    
    .ppdf-emb-sidebar {
        margin: 30px 0;
    }
    
    .ppdf-emb-sidebar-header {
        padding: 16px 18px;
        flex-wrap: wrap;
    }
    
    .ppdf-emb-sidebar-button {
        padding: 16px 18px;
    }
    
    .ppdf-emb-sidebar-icon {
        width: 36px;
        height: 36px;
    }
    
    .ppdf-emb-modal-content {
        width: 95%;
        max-width: 95%;
    }
    
    .ppdf-emb-pdf-modal .ppdf-emb-modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .ppdf-emb-pdf-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .ppdf-emb-pdf-link {
        padding: 15px;
        gap: 12px;
    }
    
    .ppdf-emb-icon {
        width: 40px;
        height: 40px;
    }
    
    .ppdf-emb-filename {
        font-size: 14px;
    }
    
    .ppdf-emb-filesize {
        font-size: 12px;
    }
    
    .ppdf-emb-sidebar {
        margin: 30px 0;
        border-radius: 8px;
    }
    
    .ppdf-emb-sidebar-header {
        padding: 15px;
        flex-wrap: wrap;
    }
    
    .ppdf-emb-sidebar-title {
        font-size: 16px;
        gap: 8px;
    }
    
    .ppdf-emb-sidebar-title svg {
        width: 18px;
        height: 18px;
    }
    
    .ppdf-emb-sidebar-badge {
        font-size: 11px;
        padding: 5px 10px;
    }
    
    .ppdf-emb-sidebar-notice {
        padding: 12px 15px;
        font-size: 13px;
    }
    
    .ppdf-emb-sidebar-button {
        padding: 15px;
        gap: 12px;
    }
    
    .ppdf-emb-sidebar-button:hover {
        padding-left: 15px;
    }
    
    .ppdf-emb-sidebar-icon {
        width: 36px;
        height: 36px;
    }
    
    .ppdf-emb-sidebar-filename {
        font-size: 14px;
    }
    
    .ppdf-emb-sidebar-meta {
        font-size: 12px;
    }
    
    .ppdf-emb-modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .ppdf-emb-modal-body {
        padding: 30px 20px 20px;
    }
    
    .ppdf-emb-modal-body h3 {
        font-size: 18px;
    }
    
    .ppdf-emb-pdf-modal .ppdf-emb-modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .ppdf-emb-modal-close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }
}