/**
 * Attachments Display in Category Pages
 * Mostra allegati scaricabili nelle pagine categoria
 */

/* ===== SEZIONE ALLEGATI ===== */

/* Container allegati */
.post-attachments {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #dee2e6;
}

.post-attachments-title {
    font-size: 14px;
    font-weight: 700;
    color: #0066cc;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-attachments-title::before {
    content: "📎";
    font-size: 16px;
}

/* Lista allegati */
.attachments-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

/* Singolo allegato */
.attachment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.attachment-item:hover {
    background-color: #e9ecef;
    border-color: #0066cc;
    transform: translateX(4px);
}

/* Icona tipo file */
.attachment-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border-radius: 4px;
    font-size: 20px;
    border: 1px solid #dee2e6;
}

/* Icone specifiche per tipo file */
.attachment-icon.pdf {
    background-color: #fff5f5;
    border-color: #dc3545;
    color: #dc3545;
}

.attachment-icon.doc,
.attachment-icon.docx {
    background-color: #f0f7ff;
    border-color: #0066cc;
    color: #0066cc;
}

.attachment-icon.xls,
.attachment-icon.xlsx {
    background-color: #f0fff4;
    border-color: #28a745;
    color: #28a745;
}

.attachment-icon.zip,
.attachment-icon.rar {
    background-color: #fff9f0;
    border-color: #ffc107;
    color: #ffc107;
}

/* Info allegato */
.attachment-info {
    flex-grow: 1;
    min-width: 0;
    /* Per ellipsis */
}

.attachment-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-meta {
    font-size: 12px;
    color: #6c757d;
    display: flex;
    gap: 12px;
}

.attachment-size,
.attachment-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Link download */
.attachment-download {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: #0066cc;
    color: #ffffff !important;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 18px;
}

.attachment-download:hover {
    background-color: #004999;
    transform: scale(1.1);
}

.attachment-download::before {
    content: "⬇";
}

/* ===== LAYOUT ALTERNATIVO: GRIGLIA ===== */

/* Griglia allegati (per molti file) */
.attachments-list.grid-layout {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.attachments-list.grid-layout .attachment-item {
    flex-direction: column;
    text-align: center;
    padding: 16px;
}

.attachments-list.grid-layout .attachment-icon {
    width: 60px;
    height: 60px;
    font-size: 30px;
}

.attachments-list.grid-layout .attachment-info {
    width: 100%;
}

.attachments-list.grid-layout .attachment-name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.attachments-list.grid-layout .attachment-download {
    width: 100%;
    height: 40px;
    border-radius: 4px;
}

.attachments-list.grid-layout .attachment-download::before {
    content: "⬇ Scarica";
}

/* ===== BADGE CONTATORE ALLEGATI ===== */

/* Badge numero allegati */
.attachments-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    background-color: #0066cc;
    color: #ffffff;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}

/* ===== NESSUN ALLEGATO ===== */

.no-attachments {
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
    text-align: center;
    color: #6c757d;
    font-size: 13px;
    font-style: italic;
}

/* ===== RESPONSIVE MOBILE ===== */

@media (max-width: 768px) {
    .attachment-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .attachment-info {
        width: 100%;
    }

    .attachment-name {
        white-space: normal;
    }

    .attachment-download {
        width: 100%;
        height: 40px;
    }

    .attachment-download::before {
        content: "⬇ Scarica";
    }

    /* Griglia a 1 colonna su mobile */
    .attachments-list.grid-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .post-attachments {
        margin-top: 12px;
        padding-top: 12px;
    }

    .attachment-item {
        padding: 12px;
    }

    .attachment-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}

/* ===== INTEGRAZIONE CON CARD ARTICOLO ===== */

/* Allegati dentro card categoria */
.category article .post-attachments,
.archive article .post-attachments {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #dee2e6;
}

/* ===== STILI AVANZATI ===== */

/* Animazione download */
@keyframes downloadPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.attachment-download:active {
    animation: downloadPulse 0.3s ease;
}

/* Tooltip tipo file */
.attachment-icon[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background-color: #333;
    color: #fff;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    margin-bottom: 4px;
}

/* ===== PRINT STYLES ===== */

@media print {
    .post-attachments {
        page-break-inside: avoid;
    }

    .attachment-download {
        display: none;
    }

    .attachment-item {
        border: 1px solid #000;
        background-color: transparent;
    }

    .attachment-name::after {
        content: " (" attr(href) ")";
        font-size: 10px;
        color: #666;
    }
}

/* ===== ACCESSIBILITY ===== */

/* Focus visibile */
.attachment-download:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}