/**
 * Estilos Frontend del Explorador de Archivos (AFDM).
 */

:root {
    --afdm-fe-primary: #4f46e5;
    --afdm-fe-primary-hover: #4338ca;
    --afdm-fe-text: #374151;
    --afdm-fe-text-muted: #6b7280;
    --afdm-fe-bg-light: #f9fafb;
    --afdm-fe-border: #f3f4f6;
    --afdm-fe-radius: 8px;
    --afdm-fe-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.afdm-fe-explorer {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--afdm-fe-text);
    border: 1px solid var(--afdm-fe-border);
    border-radius: var(--afdm-fe-radius);
    background: #fff;
    box-shadow: var(--afdm-fe-shadow);
    margin: 20px 0;
    overflow: hidden;
}

/* Layout del Explorador */
.afdm-fe-layout {
    display: flex;
    min-height: 400px;
    border-top: 1px solid var(--afdm-fe-border);
}

/* Sidebar de Carpetas */
.afdm-fe-sidebar {
    flex: 0 0 240px;
    border-right: 1px solid var(--afdm-fe-border);
    background: var(--afdm-fe-bg-light);
    padding: 15px;
    box-sizing: border-box;
}

.afdm-fe-sidebar h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--afdm-fe-text-muted);
    letter-spacing: 0.05em;
}

.afdm-fe-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.afdm-fe-tree-item {
    margin: 2px 0;
}

.afdm-fe-tree-row {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.afdm-fe-tree-row:hover {
    background: rgba(0, 0, 0, 0.03);
}

.afdm-fe-tree-row.active {
    background: #e0e7ff;
    color: var(--afdm-fe-primary);
    font-weight: 500;
}

.afdm-fe-tree-toggle {
    width: 16px;
    margin-right: 4px;
    font-size: 10px;
    color: var(--afdm-fe-text-muted);
    display: inline-block;
    text-align: center;
}

.afdm-fe-tree-icon {
    margin-right: 8px;
    color: #fbbf24;
    font-size: 15px;
    display: inline-block;
    vertical-align: middle;
}

.afdm-fe-tree-row.active .afdm-fe-tree-icon {
    color: var(--afdm-fe-primary);
}

.afdm-fe-tree-children {
    list-style: none;
    padding-left: 15px;
    margin: 0;
    border-left: 1px dotted var(--afdm-fe-border);
}

/* Área de contenido del listado */
.afdm-fe-main {
    flex-grow: 1;
    padding: 20px;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Navbar superior del explorador */
.afdm-fe-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
    flex-wrap: wrap;
    padding: 20px 20px 0 20px;
}

.afdm-fe-breadcrumb {
    font-size: 14px;
    font-weight: 500;
    color: var(--afdm-fe-text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.afdm-fe-breadcrumb-item {
    cursor: pointer;
    transition: color 0.2s;
}

.afdm-fe-breadcrumb-item:hover {
    color: var(--afdm-fe-primary);
}

.afdm-fe-breadcrumb-separator {
    color: #d1d5db;
}

.afdm-fe-search {
    position: relative;
}

.afdm-fe-search-input {
    padding: 6px 12px 6px 32px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.afdm-fe-search-input:focus {
    border-color: var(--afdm-fe-primary);
}

.afdm-fe-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--afdm-fe-text-muted);
    font-size: 12px;
}

/* Tabla de Archivos */
.afdm-fe-files-list {
    flex-grow: 1;
}

.afdm-fe-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.afdm-fe-table th {
    padding: 10px;
    border-bottom: 2px solid #e5e7eb;
    color: var(--afdm-fe-text-muted);
    font-weight: 600;
}

.afdm-fe-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.afdm-fe-file-info {
    display: flex;
    align-items: center;
}

.afdm-fe-file-icon {
    font-size: 20px;
    margin-right: 12px;
    color: var(--afdm-fe-text-muted);
}

.afdm-fe-file-title {
    font-weight: 600;
    color: #111827;
}

.afdm-fe-file-desc {
    font-size: 11px;
    color: var(--afdm-fe-text-muted);
    margin-top: 2px;
}

/* Botón de Descarga */
.afdm-fe-download-btn {
    display: inline-flex;
    align-items: center;
    background: var(--afdm-fe-primary);
    color: #fff !important;
    text-decoration: none !important;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 12px;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.afdm-fe-download-btn:hover {
    background: var(--afdm-fe-primary-hover);
}

.afdm-fe-download-btn:active {
    transform: scale(0.98);
}

.afdm-fe-download-btn svg {
    margin-right: 6px;
}

/* Estado Vacío */
.afdm-fe-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--afdm-fe-text-muted);
    text-align: center;
}

.afdm-fe-empty-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

/* Spinner cargando */
.afdm-fe-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.afdm-fe-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid var(--afdm-fe-primary);
    border-radius: 50%;
    animation: afdmFeSpin 1s linear infinite;
}

@keyframes afdmFeSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 640px) {
    .afdm-fe-layout {
        flex-direction: column;
    }
    .afdm-fe-sidebar {
        flex: 1 1 auto;
        border-right: none;
        border-bottom: 1px solid var(--afdm-fe-border);
    }
    .afdm-fe-table th:nth-child(2),
    .afdm-fe-table td:nth-child(2),
    .afdm-fe-table th:nth-child(3),
    .afdm-fe-table td:nth-child(3) {
        display: none;
    }
}

/* Vista de Cuadrícula (Grid) */
.afdm-fe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    padding: 10px 0;
}

.afdm-fe-grid-card {
    background: #fff;
    border: 1px solid var(--afdm-fe-border);
    border-radius: var(--afdm-fe-radius);
    padding: 16px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.afdm-fe-grid-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #cbd5e1;
}

.afdm-fe-grid-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.afdm-fe-grid-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--afdm-fe-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.afdm-fe-grid-desc {
    font-size: 11px;
    color: var(--afdm-fe-text-muted);
    margin-bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.afdm-fe-grid-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--afdm-fe-text-muted);
    margin-top: auto;
    border-top: 1px solid var(--afdm-fe-border);
    padding-top: 10px;
}

.afdm-fe-grid-meta .badge {
    background: #e2e8f0;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

/* Vista de Lista Minimalista */
.afdm-fe-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 0;
}

.afdm-fe-list-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid var(--afdm-fe-border);
    border-radius: var(--afdm-fe-radius);
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.afdm-fe-list-item:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.afdm-fe-list-icon {
    font-size: 24px;
    margin-right: 14px;
    display: inline-flex;
    align-items: center;
}

.afdm-fe-list-link {
    font-size: var(--afdm-fe-font-size, 13px);
    font-weight: 600;
    color: var(--afdm-fe-text, #334155);
    text-decoration: none;
    transition: color 0.15s;
    flex-grow: 1;
    line-height: 1.4;
}

.afdm-fe-list-link:hover {
    color: var(--afdm-fe-primary);
}

.afdm-fe-list-btn {
    color: var(--afdm-fe-primary);
    border: 1px solid var(--afdm-fe-primary);
    background: #fff;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
}

.afdm-fe-list-btn:hover {
    background: var(--afdm-fe-primary);
    color: #fff !important;
}

/* Tabla de Archivos Frontend */
.afdm-fe-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.afdm-fe-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: #64748b;
    font-size: 11px;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e2e8f0;
    text-transform: uppercase;
}

.afdm-fe-table td {
    padding: 14px 16px;
    vertical-align: middle;
}

.afdm-fe-table tr {
    transition: background-color 0.15s;
}

.afdm-fe-table tbody tr:hover {
    background-color: #f8fafc;
}

/* Acordeón de Categorías */
.afdm-fe-accordion-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.afdm-fe-accordion-item {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.afdm-fe-accordion-item:hover {
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    border-color: #cbd5e1;
}

.afdm-fe-accordion-header {
    display: flex;
    align-items: center;
    padding: 18px 28px;
    cursor: pointer;
    background: #fff;
    user-select: none;
    transition: background-color 0.15s;
}

.afdm-fe-accordion-header:hover {
    background-color: #f8fafc;
}

.afdm-fe-accordion-header.active {
    border-bottom: 1px solid #e2e8f0;
}

.afdm-fe-accordion-icon {
    font-size: 18px;
    font-weight: bold;
    margin-right: 20px;
    color: var(--afdm-fe-primary, #4f46e5);
    display: inline-block;
    width: 16px;
    text-align: center;
}

.afdm-fe-accordion-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
}

.afdm-fe-accordion-content {
    padding: 20px;
    background: #fff;
}

.afdm-fe-subfolder-card {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e2e8f0;
    padding: 12px 18px;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.afdm-fe-subfolder-card:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.afdm-fe-back-button {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
    user-select: none;
    transition: color 0.15s;
}

.afdm-fe-back-button:hover {
    color: var(--afdm-fe-primary, #4f46e5);
}

/* Botones de Compartir Enlace */
.afdm-fe-share-btn:hover,
.afdm-fe-share-file-btn:hover {
    opacity: 1 !important;
}
