/* =========================================================================
   Modal de acesso aos catalogos
   ========================================================================= */
#afg-cat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 24, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 99990;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity .25s ease;
}

#afg-cat-overlay.is-open {
    display: flex;
    opacity: 1;
}

.afg-cat-modal {
    background: #fff;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(16px);
    transition: transform .25s ease;
    font-family: 'Montserrat', system-ui, sans-serif;
    color: #1d1d1f;
}

#afg-cat-overlay.is-open .afg-cat-modal {
    transform: translateY(0);
}

.afg-cat-modal.is-gallery {
    max-width: 880px;
}

.afg-cat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 26px 28px 8px;
}

.afg-cat-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: .2px;
}

.afg-cat-header p {
    margin: 6px 0 0;
    font-size: 13px;
    color: #6b6b70;
}

.afg-cat-close {
    border: none;
    background: #f1f1f3;
    color: #444;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background .2s ease;
}

.afg-cat-close:hover {
    background: #e3e3e6;
}

.afg-cat-body {
    padding: 12px 28px 28px;
}

.afg-cat-field {
    margin-bottom: 16px;
}

.afg-cat-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #6b6b70;
    margin-bottom: 6px;
}

.afg-cat-field input {
    width: 100%;
    border: 1.5px solid #e2e2e6;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
    color: #1d1d1f;
    background: #fafafb;
    transition: border-color .2s ease, background .2s ease;
    box-sizing: border-box;
}

.afg-cat-field input:focus {
    outline: none;
    border-color: #1d1d1f;
    background: #fff;
}

.afg-cat-field.has-error input {
    border-color: #e0322f;
    background: #fff5f5;
}

.afg-cat-error {
    display: none;
    color: #e0322f;
    font-size: 12px;
    margin-top: 5px;
}

.afg-cat-field.has-error .afg-cat-error {
    display: block;
}

.afg-cat-submit {
    width: 100%;
    border: none;
    background: #1d1d1f;
    color: #fff;
    padding: 14px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease, opacity .2s ease;
    margin-top: 4px;
}

.afg-cat-submit:hover {
    background: #000;
}

.afg-cat-submit:disabled {
    opacity: .6;
    cursor: default;
}

.afg-cat-alert {
    display: none;
    background: #fff5f5;
    border: 1px solid #f3c8c7;
    color: #c0322f;
    font-size: 13px;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 16px;
}

.afg-cat-alert.is-visible {
    display: block;
}

/* Estado de carregamento */
.afg-cat-loading {
    text-align: center;
    padding: 40px 20px;
    color: #6b6b70;
}

.afg-cat-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid #e2e2e6;
    border-top-color: #1d1d1f;
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: afg-cat-spin .8s linear infinite;
}

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

/* Galeria de arquivos */
.afg-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.afg-cat-item {
    display: block;
    border: 1px solid #ececef;
    border-radius: 12px;
    overflow: hidden;
    background: #fafafb;
    text-decoration: none;
    color: #1d1d1f;
    transition: transform .18s ease, box-shadow .18s ease;
}

.afg-cat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    text-decoration: none;
    color: #1d1d1f;
}

.afg-cat-thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
    background: #f0f0f2;
}

.afg-cat-pdf {
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #c0322f;
    font-weight: 600;
    font-size: 13px;
}

.afg-cat-pdf svg {
    width: 40px;
    height: 40px;
}

.afg-cat-name {
    padding: 9px 10px;
    font-size: 12px;
    color: #6b6b70;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.afg-cat-empty {
    text-align: center;
    color: #6b6b70;
    padding: 30px 10px;
}

/* Cursor de zoom nas imagens da grade (a galeria estilizada abre ao clicar) */
.afg-cat-img-link {
    cursor: zoom-in;
}

/* O lightbox da galeria fica acima do modal de acesso do catálogo */
.afg-cat-lightbox {
    z-index: 100001;
}

@media (max-width: 520px) {
    .afg-cat-header, .afg-cat-body { padding-left: 18px; padding-right: 18px; }
    .afg-cat-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
