/* ========================================
   SimpleDown Frontend - Clean & Minimalista 2025
   ======================================== */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css');
@import url('https://fonts.googleapis.com/css2?family=Bai+Jamjuree:wght@400;500;600;700&display=swap');

/* Container Principal */
.simpledown-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 15px;
    font-family: 'Bai Jamjuree', 'Roboto', 'Arial', 'Helvetica', sans-serif !important;
    background: #ffffff;
}

/* Título principal */
.simpledown-header-panel {
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 12px;
    padding: 20px 32px;
    margin: 30px auto 20px auto;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    max-width: 1200px;
}
.simpledown-header-panel h2 {
    font-size: 2.6em;
    font-weight: 700;
    color: #000000;
    margin: 0;
}

/* Controles superiores: busca + filtros */
.simpledown-top-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 40px auto 50px auto;
    max-width: 1200px;
    padding: 0 15px;
    flex-wrap: wrap;
}
.search-box-wrapper { flex: 2; min-width: 300px; }
.filter-select-wrapper { flex: 1; min-width: 240px; }

/* Busca */
.search-box-outer {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 52px;
}
.simpledown-search-input {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.3em;
    border: 1px solid #dddddd;
    border-right: none;
    border-radius: 12px 0 0 12px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: border-color 0.3s ease;
    height: 100%;
    box-sizing: border-box;
}
.simpledown-search-input::placeholder { color: #aaaaaa; font-style: italic; }
.simpledown-search-input:focus { outline: none; }

/* Botão limpar busca */
.external-clear-btn {
    background: white;
    border: 1px solid #dddddd;
    border-left: none;
    color: #cccccc;
    font-size: 1.3em;
    cursor: pointer;
    padding: 0 18px;
    border-radius: 0 12px 12px 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}
.external-clear-btn:hover { background: #f5f5f5; color: #e74c3c; }

/* Filtros */
.category-filter-select {
    width: 100%;
    padding: 12px 18px;
    font-size: 1.25em;
    border: 1px solid #dddddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: border-color 0.3s ease;
}
.category-filter-select:focus { outline: none; border-color: #666666; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08); }

/* Grade de cards */
.downloads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 20px;
    grid-auto-rows: 1fr;
}

/* Card principal */
.simpledown-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Conteúdo do card */
.card-content {
    padding: 8px 20px 20px 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.file-title {
    font-size: 1.4em;
    font-weight: 700;
    color: #000000;
    margin: 8px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.file-description {
    font-size: 1.2em;
    color: #555555;
    line-height: 1.5;
    margin-top: 6px;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 6em;
}
.file-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1em;
    color: #666666;
    margin-bottom: 16px;
    padding-top: 12px;
    border-top: 1px dashed #cccccc;
}
.file-info-row span {
    display: flex;
    align-items: center;
    font-weight: 500;
}
.file-info-row i { margin-right: 8px; }
.file-info-row span:first-child i.fa-download { color: #2ecc71; }
.file-info-row span:last-child i.fa-hdd-o { color: #9b59b6; }

/* Preview no card */
.preview-btn {
    cursor: pointer;
    color: #3498db;
    font-size: 1.1em;
    margin: 0 12px;
    transition: color 0.3s ease;
}
.preview-btn:hover { color: #2980b9; }

/* Nome do arquivo + ícone + versão */
.file-name-below {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.95em;
    color: #555555;
    overflow: hidden;
}
.file-name-below i {
    margin-right: 3px !important;
}
.file-realname-truncate {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.version-badge {
    flex-shrink: 0;
    font-size: 0.8em;
    font-weight: 600;
    background: #3498db;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Ícones por tipo de arquivo */
.file-name-below i.fa-file-pdf { color: #e74c3c; }
.file-name-below i.fa-file-image { color: #3498db; }
.file-name-below i.fa-file-word { color: #2980b9; }
.file-name-below i.fa-file-excel { color: #27ae60; }
.file-name-below i.fa-file-powerpoint { color: #e67e22; }
.file-name-below i.fa-file-archive { color: #9b59b6; }
.file-name-below i.fa-file-audio { color: #f1c40f; }
.file-name-below i.fa-file-video { color: #c0392b; }
.file-name-below i.fa-file-lines { color: #7f8c8d; }
.file-name-below i.fa-file { color: #95a5a6; }

/* Rodapé do card */
.card-footer {
    padding: 18px 35px 22px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    flex-wrap: nowrap;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

/* Botões */
.details-btn-small,
.download-btn {
    flex: 1;
    max-width: 180px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 1.05em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transition: none !important;
    white-space: nowrap;
    text-decoration: none !important;
}
.details-btn-small {
    background: #2980b9;
    border: 1px solid #1f6f9b;
    color: #ffffff !important;
}
.download-btn {
    background: linear-gradient(to bottom, #5cb85c, #449d44);
    border: 1px solid #398439;
    color: #ffffff !important;
}
.details-btn-small i,
.download-btn i {
    margin-right: 10px;
    font-size: 1.2em;
    color: #ffffff !important;
}
.details-btn-small:hover,
.download-btn:hover,
.details-btn-small:focus,
.download-btn:focus,
.details-btn-small:active,
.download-btn:active {
    text-decoration: none !important;
}

/* Responsivo - botões */
@media (max-width: 768px) {
    .card-footer { padding: 16px 25px 20px; gap: 20px; }
    .details-btn-small, .download-btn { padding: 11px 18px; font-size: 1em; max-width: 160px; }
}
@media (max-width: 480px) {
    .card-footer { padding: 14px 20px 18px; gap: 16px; }
    .details-btn-small, .download-btn { padding: 10px 16px; font-size: 0.98em; max-width: 140px; }
}
@media (max-width: 360px) {
    .card-footer { flex-wrap: wrap; gap: 12px; }
    .details-btn-small, .download-btn { flex: 1 1 100%; max-width: none; }
}

/* Cabeçalho da categoria */
.simpledown-category-header {
    background: #f8f9fa;
    border-bottom: 2px solid #dddddd;
    padding: 16px 24px;
    border-radius: 12px 12px 0 0;
}
.simpledown-category-header h3 {
    font-size: 1.6em;
    font-weight: 700;
    color: #000000;
    margin: 0;
}
.category-file-count {
    font-size: 0.9em;
    font-weight: 400;
    color: #777777;
    margin-left: 8px;
}

/* Mensagem sem arquivos */
.simpledown-empty-state {
    background: #ecf0f1;
    border: 2px dashed #bdc3c7;
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    margin: 40px auto;
    max-width: 800px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}
.simpledown-empty-state p {
    font-size: 1.6em;
    font-weight: 600;
    color: #7f8c8d;
    margin: 0;
    line-height: 1.4;
}

/* Bloco de categoria */
.simpledown-category-block {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    margin-bottom: 40px;
}
.simpledown-category-block:last-child { margin-bottom: 0; }

/* Paginação */
.category-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    font-size: 1em;
    flex-wrap: wrap;
    gap: 10px;
}

/* Modal de imagem - MELHOR SOLUÇÃO */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    overflow: auto;
    padding: 20px;
    box-sizing: border-box;
}
.modal-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 90vw;
    max-height: 90vh;
    line-height: 0;
}
.modal-image-content {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.8);
}

/* Botão X fixo no canto superior direito da tela */
.modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.7);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: #ffffff;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.modal-close:hover {
    background: #e74c3c;
    transform: scale(1.1);
}
.modal-close:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.modal-close i {
    font-size: 32px;
}
/* Página de detalhes */
.simpledown-header-panel {
    padding: 30px 40px;
    margin: 30px auto 40px auto;
}
.file-name-uppercase {
    font-size: 2.8em;
    font-weight: 700;
    color: #000000;
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}
.category-breadcrumb {
    font-size: 1.4em;
    color: #444444;
}
.category-breadcrumb strong em {
    color: #1976d2;
    font-style: italic;
    font-weight: 600;
}
.details-card-expanded {
    max-width: 1400px;
    width: 95%;
    margin: 0 auto 40px auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
}
.details-card-content { padding: 40px; }
.file-description-full {
    font-size: 1.3em;
    line-height: 1.8;
    color: #333;
    margin: 0 0 50px 0;
    white-space: pre-wrap;
}
.file-description-full.no-description {
    color: #999;
    font-style: italic;
    font-size: 1.4em;
}
.details-single-info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    font-size: 1.3em;
    color: #555;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 16px;
    border: 1px solid #eee;
}

/* Link "Voltar para Downloads" */
.back-link {
    text-align: center;
    margin: 20px 0 60px;
    font-size: 1.4em;
}
.back-link a {
    color: #3498db;
    text-decoration: none;
    padding: 12px 30px;
    border: 2px solid #3498db;
    border-radius: 12px;
    transition: all 0.3s;
    font-weight: 600;
}
.back-link a:hover {
    background: #3498db;
    color: white;
    text-decoration: none;
}

/* Responsivo geral */
@media (max-width: 992px) {
    .simpledown-top-controls { flex-direction: column; align-items: stretch; }
    .filter-select-wrapper { margin-top: 15px; }
    .details-card-expanded { width: 98%; }
}
@media (max-width: 768px) {
    .downloads-grid { grid-template-columns: 1fr; padding: 15px; }
    .simpledown-header-panel { padding: 20px; }
    .simpledown-header-panel h2 { font-size: 2.2em; }
    .file-name-uppercase { font-size: 2.2em; }
    .category-breadcrumb { font-size: 1.2em; }
    .file-description-full { font-size: 1.4em; }
}
@media (max-width: 480px) {
    .simpledown-header-panel { padding: 20px; }
    .file-name-uppercase { font-size: 1.9em; }
}

/* Título do arquivo + categoria na mesma linha */
.file-title-with-category {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 8px 0 12px 0;
    flex-wrap: wrap;
}
.file-title {
    font-size: 1.35em;
    font-weight: 700;
    color: #000000;
    margin: 0;
    line-height: 1.3;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.file-category-label {
    font-size: 0.92em;
    font-weight: 400;
    color: #777777;
    text-transform: lowercase;
    white-space: nowrap;
    opacity: 0.9;
}

/* Responsivo: em telas pequenas, a categoria vai para baixo */
@media (max-width: 480px) {
    .file-title-with-category {
        flex-direction: column;
        gap: 4px;
    }
    .file-category-label {
        font-size: 0.88em;
    }
}

/* Cores dos ícones na página de detalhes */
.details-single-info-row i {
    margin-right: -3px;
    font-size: 1.3em;
}
.details-single-info-row .info-downloads i.fa-download { color: #2ecc71; }
.details-single-info-row .info-size i.fa-hdd-o { color: #9b59b6; }
.details-single-info-row .details-file-name i { font-size: 1.4em; }

/* Cores específicas por tipo de arquivo */
.details-single-info-row i.fa-file-pdf { color: #e74c3c; }
.details-single-info-row i.fa-file-image { color: #3498db; }
.details-single-info-row i.fa-file-word { color: #2980b9; }
.details-single-info-row i.fa-file-excel { color: #27ae60; }
.details-single-info-row i.fa-file-powerpoint { color: #e67e22; }
.details-single-info-row i.fa-file-archive { color: #9b59b6; }
.details-single-info-row i.fa-file-audio { color: #f1c40f; }
.details-single-info-row i.fa-file-video { color: #c0392b; }
.details-single-info-row i.fa-file-lines { color: #7f8c8d; }
.details-single-info-row i.fa-file { color: #95a5a6; }

//* Versão na página de detalhes */
.info-version {
    font-size: 0.95em;
    color: #555;
    white-space: nowrap;
}
.info-version .version-icon {
    color: #e67e22 !important;
    font-size: 1.2em;
    margin-right: -5px;  /* <--- este é o culpado! */
}
.info-version:hover .version-icon {
    color: #d35400 !important;
}

/* Truncamento do nome real na página de detalhes */
.details-file-name {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.file-realname-truncate {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Garante que os outros itens não sejam empurrados */
.info-downloads,
.info-size,
.info-version,
.preview-btn {
    flex-shrink: 0;
    white-space: nowrap;
}

/* =====================================
   Estilos para nova página de detalhes (layout com thumbnail à esquerda)
   ===================================== */

/* Wrapper principal: thumbnail + descrição lado a lado */
.details-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    align-items: flex-start;
    margin-bottom: 40px;
}

/* Thumbnail fixa (esquerda) */
.details-thumbnail {
    flex: 0 0 220px;
    width: 220px;
    height: 220px;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #eee;
}

.thumbnail-fixed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

/* Sem thumbnail */
.details-thumbnail.no-thumbnail {
    flex-direction: column;
    text-align: center;
    color: #999;
    font-size: 0.95em;
}

.details-thumbnail.no-thumbnail i {
    color: #bdc3c7;
    margin-bottom: 12px;
}

.details-thumbnail.no-thumbnail p {
    margin: 0;
    color: #777;
}

/* Descrição à direita */
.details-description {
    flex: 1;
    min-width: 300px;
}

/* Ajuste na responsividade */
@media (max-width: 992px) {
    .details-wrapper {
        flex-direction: column;
        align-items: center;
    }
    .details-thumbnail {
        flex: 0 0 auto;
        width: 280px;
        height: 280px;
    }
}

@media (max-width: 480px) {
    .details-thumbnail {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
    .thumbnail-fixed {
        object-fit: contain;
    }
}

/* Ajustes finos nos itens de informação */
.details-single-info-row {
    gap: 24px 40px; /* mais espaço em telas maiores */
    padding: 30px;
    margin-top: 20px;
}

.details-single-info-row .preview-btn {
    margin-left: auto; /* joga o botão de preview para a direita */
}

/* Botão de download no footer (já existe, só reforçando) */
.details-card-footer {
    padding: 30px 40px;
}
/* Quando não tem thumbnail, descrição ocupa toda a largura */
.details-wrapper {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    margin-bottom: 40px;
}

.details-thumbnail {
    flex: 0 0 220px;
    width: 220px;
    height: 220px;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #eee;
}

.details-description {
    flex: 1;
    min-width: 300px;
}

/* Classe para ocupar toda a largura quando não tem thumbnail */
.details-description.full-width {
    width: 100%;
    flex: 1 1 100%;
}

@media (max-width: 992px) {
    .details-wrapper {
        flex-direction: column;
        align-items: center;
    }
    .details-thumbnail {
        flex: 0 0 auto;
        width: 280px;
        height: 280px;
    }
    .details-description.full-width {
        width: 100%;
    }
}