/* Directorio de PDFs - Estilos Responsive (Cards en móvil) */

:root {
    --docsdir-primary: #1d365c;
    --docsdir-primary-hover: #152844;
    --docsdir-secondary: #4a5f7f;
    --docsdir-bg-light: #f8f9fa;
    --docsdir-border: #e1e4e8;
    --docsdir-text: #24292e;
    --docsdir-disabled: #999;
}

.docsdir {
    --gap: 1.5rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--docsdir-text);
}

/* Reset de estilos de tema */
.docsdir button,
.docsdir a.docsdir__action-btn,
.docsdir button.docsdir__action-btn {
    font-family: inherit !important;
    line-height: normal !important;
}

/* Barra de búsqueda */
.docsdir__searchbar {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.docsdir__searchbar input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--docsdir-border);
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.docsdir__searchbar input:focus {
    outline: none;
    border-color: var(--docsdir-primary);
}

/* Botones */
.docsdir__btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 15px !important;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none !important;
    box-shadow: none !important;
}

.docsdir__btn--primary,
button.docsdir__btn--primary {
    background: var(--docsdir-primary) !important;
    background-color: var(--docsdir-primary) !important;
    color: white !important;
}

.docsdir__btn--primary:hover,
button.docsdir__btn--primary:hover {
    background: var(--docsdir-primary-hover) !important;
    background-color: var(--docsdir-primary-hover) !important;
    color: white !important;
}

.docsdir__btn--secondary,
button.docsdir__btn--secondary {
    background: var(--docsdir-primary) !important;
    background-color: var(--docsdir-primary) !important;
    color: white !important;
}

.docsdir__btn--secondary:hover:not(:disabled),
button.docsdir__btn--secondary:hover:not(:disabled) {
    background: var(--docsdir-primary-hover) !important;
    background-color: var(--docsdir-primary-hover) !important;
    color: white !important;
}

.docsdir__btn:disabled,
button.docsdir__btn:disabled {
    background: #e1e4e8 !important;
    background-color: #e1e4e8 !important;
    color: var(--docsdir-disabled) !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

/* Layout principal */
.docsdir__layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: var(--gap);
    align-items: start;
}

/* Filtros laterales */
.docsdir__filters {
    background: var(--docsdir-bg-light);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--docsdir-border);
}

.docsdir__filters h4 {
    margin: 0 0 0.75rem 0;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--docsdir-primary);
    letter-spacing: 0.5px;
}

.docsdir__radio {
    display: block;
    margin: 0.5rem 0;
    cursor: pointer;
    font-size: 14px;
}

.docsdir__radio input {
    margin-right: 0.5rem;
    cursor: pointer;
}

.docsdir__hsep {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--docsdir-border);
}

/* Barra de acciones masivas */
.docsdir__bulkbar {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--docsdir-bg-light);
    border-radius: 6px;
    border: 1px solid var(--docsdir-border);
}

.docsdir__select-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
}

.docsdir__select-all input {
    cursor: pointer;
}

.docsdir__bulk-actions {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
}

/* Tabla de resultados */
.docsdir__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--docsdir-border);
    border-radius: 8px;
    overflow: hidden;
}

.docsdir__table thead {
    background: var(--docsdir-primary);
    color: white;
}

.docsdir__table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.docsdir__table td {
    padding: 1rem;
    border-bottom: 1px solid var(--docsdir-border);
    font-size: 14px;
}

.docsdir__table tbody tr {
    background: white;
    transition: background-color 0.2s;
}

.docsdir__table tbody tr:hover {
    background: #f8f9fa;
}

.docsdir__table tbody tr:last-child td {
    border-bottom: none;
}

.docsdir__loading,
.docsdir__table tbody td[colspan] {
    text-align: center;
    color: var(--docsdir-disabled);
    padding: 2rem;
}

/* Acciones individuales */
.docsdir__actions {
    display: flex;
    gap: 0.5rem;
}

.docsdir__action-btn,
a.docsdir__action-btn,
button.docsdir__action-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
    border: 1px solid var(--docsdir-border) !important;
    background: white !important;
    background-color: white !important;
    border-radius: 6px !important;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--docsdir-primary) !important;
    text-decoration: none !important;
    font-size: 16px;
    box-shadow: none !important;
}

.docsdir__action-btn:hover,
a.docsdir__action-btn:hover,
button.docsdir__action-btn:hover {
    background: var(--docsdir-primary) !important;
    background-color: var(--docsdir-primary) !important;
    border-color: var(--docsdir-primary) !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(29, 54, 92, 0.2) !important;
}

.docsdir__actions svg {
    width: 18px;
    height: 18px;
}

/* Checkbox */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--docsdir-primary);
}

/* ========================================
   RESPONSIVE DESIGN - CARDS EN MÓVIL
   ======================================== */

/* Tablet (max 1024px) */
@media (max-width: 1024px) {
    .docsdir__layout {
        grid-template-columns: 220px 1fr;
    }
}

/* Tablet petit / Mòbil (max 768px) */
@media (max-width: 768px) {
    .docsdir {
        --gap: 1rem;
    }
    
    /* Layout en columna */
    .docsdir__layout {
        grid-template-columns: 1fr;
    }
    
    /* Búsqueda */
    .docsdir__searchbar {
        flex-wrap: wrap;
    }
    
    .docsdir__searchbar input {
        min-width: 200px;
    }
    
    /* Bulk actions */
    .docsdir__bulkbar {
        flex-wrap: wrap;
    }
    
    .docsdir__bulk-actions {
        flex-wrap: wrap;
        width: 100%;
    }
    
    /* ===========================================
       CONVERTIR TABLA EN CARDS
       =========================================== */
    
    .docsdir__table {
        border: none;
        background: transparent;
    }
    
    .docsdir__table thead {
        display: none;
    }
    
    .docsdir__table tbody {
        display: block;
    }
    
    .docsdir__table tbody tr {
        display: block;
        position: relative;
        margin-bottom: 1rem;
        padding: 1.25rem;
        padding-right: 3.5rem;
        background: white !important;
        border: 1px solid var(--docsdir-border);
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
        transition: all 0.2s;
    }
    
    .docsdir__table tbody tr:hover {
        background: white !important;
        box-shadow: 0 4px 12px rgba(29, 54, 92, 0.12);
        transform: translateY(-2px);
    }
    
    .docsdir__table td {
        display: block;
        padding: 0;
        border: none;
        text-align: left;
        background: transparent !important;
    }
    
    /* Checkbox a la cantonada superior dreta */
    .docsdir__table td:first-child {
        position: absolute;
        top: 1.25rem;
        right: 1.25rem;
        padding: 0;
    }
    
    /* Títol del document (gran i destacat) */
    .docsdir__table td:nth-child(2) {
        font-size: 17px;
        font-weight: 600;
        color: var(--docsdir-primary);
        margin-bottom: 1rem;
        padding-right: 2rem;
        line-height: 1.3;
    }
    
    /* Idioma */
    .docsdir__table td:nth-child(3) {
        font-size: 14px;
        color: var(--docsdir-text);
        margin-bottom: 0.5rem;
    }
    
    .docsdir__table td:nth-child(3)::before {
        content: "Idioma: ";
        font-weight: 600;
    }
    
    /* Formato */
    .docsdir__table td:nth-child(4) {
        font-size: 14px;
        color: var(--docsdir-text);
        margin-bottom: 0;
    }
    
    .docsdir__table td:nth-child(4)::before {
        content: "Formato: ";
        font-weight: 600;
    }
    
    /* Accions (separades amb línia) */
    .docsdir__table td:nth-child(5) {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--docsdir-border);
    }
    
    .docsdir__actions {
        justify-content: flex-start;
        gap: 0.75rem;
    }
    
    /* Assegurar que els botons d'acció es vegin bé */
    .docsdir__action-btn,
    a.docsdir__action-btn,
    button.docsdir__action-btn {
        background: var(--docsdir-bg-light) !important;
        background-color: var(--docsdir-bg-light) !important;
        border: 1px solid var(--docsdir-border) !important;
    }
}

/* Mòbil (max 480px) */
@media (max-width: 480px) {
    .docsdir__searchbar {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .docsdir__searchbar input {
        width: 100%;
        min-width: 100%;
        font-size: 16px; /* Evita zoom en iOS */
    }
    
    .docsdir__btn {
        width: 100%;
    }
    
    .docsdir__bulkbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .docsdir__bulk-actions {
        margin-left: 0;
        justify-content: stretch;
    }
    
    .docsdir__bulk-actions button {
        flex: 1;
    }
    
    .docsdir__filters {
        padding: 1rem;
    }
    
    /* Cards més compactes */
    .docsdir__table tbody tr {
        padding: 0.75rem;
        padding-right: 2.5rem;
    }
    
    .docsdir__table td:nth-child(2) {
        font-size: 15px;
    }
}

/* Mòbil molt petit (max 360px) */
@media (max-width: 360px) {
    .docsdir {
        font-size: 14px;
    }
    
    .docsdir__btn {
        font-size: 14px !important;
        padding: 0.6rem 1rem !important;
    }
    
    .docsdir__action-btn,
    a.docsdir__action-btn,
    button.docsdir__action-btn {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
    }
    
    .docsdir__actions svg {
        width: 16px;
        height: 16px;
    }
}

/* Force white backgrounds en cards mobile - EXTRA PROTECTION */
@media (max-width: 768px) {
    .docsdir__table tbody tr,
    .docsdir__table tbody tr:hover,
    .docsdir__table tbody tr:nth-child(odd),
    .docsdir__table tbody tr:nth-child(even),
    .docsdir__table td {
        background: white !important;
        background-color: white !important;
    }
    
    .docsdir__table td:nth-child(5) {
        background: transparent !important;
    }
}

/* Print styles */
@media print {
    .docsdir__searchbar,
    .docsdir__filters,
    .docsdir__bulkbar,
    .docsdir__actions {
        display: none !important;
    }
    
    .docsdir__layout {
        grid-template-columns: 1fr;
    }
}
/* Paginación */
.docsdir__pagination {
    margin-top: 1.5rem;
    text-align: center;
}

#docsdir-load-more {
    margin: 0 auto;
}