/*
 * FabLab VOX Viewer - App Shell CSS (SPA: biblioteca, carrusel, grid, toasts)
 * FASE 3 (2026-06-11): extraccion BYTE-FIEL del bloque <style> de templates/app.php.
 * Sin limpieza ni reorganizacion en este paso (eso es un paso posterior, regla del informe).
 * Debe cargarse DESPUES de layer-controls.css (se encola con dependencia).
 */

/* ========================================== */
/* LAYOUT GENERAL */
/* ========================================== */
.fablab-vox-app {
    width: 100%;
    min-height: 100vh;
    position: relative;
    background: #f0f0f0;
}

.fablab-view {
    display: none;
    width: 100%;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

.fablab-view.active {
    display: block;
}

/* ========================================== */
/* BIBLIOTECA - HEADER */
/* ========================================== */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.biblioteca-titulo {
    text-align: center;
    margin: 0;
    font-size: 28px;
    color: #333;
    flex: 1;
}

.context-indicator {
    display: flex;
    gap: 8px;
    align-items: center;
}

.context-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.context-badge.pwa { background: #3B82F6; color: white; }
.context-badge.web { background: #6B7280; color: white; }
.context-badge.online { background: #10B981; color: white; }
.context-badge.offline { background: #EF4444; color: white; }

/* ========================================== */
/* BARRA DE BÚSQUEDA */
/* ========================================== */
.biblioteca-search-container {
    max-width: 600px;
    margin: 0 auto 25px;
    padding: 0 15px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    padding: 8px 15px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.search-wrapper:focus-within {
    border-color: #0066cc;
    box-shadow: 0 4px 12px rgba(0,102,204,0.15);
}

.search-icon {
    color: #666;
    margin-right: 10px;
    flex-shrink: 0;
    transition: color 0.3s ease;
}

.search-wrapper:focus-within .search-icon { color: #0066cc; }

.biblioteca-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    padding: 5px 0;
    background: transparent;
    color: #333;
}

.biblioteca-search-input::placeholder { color: #999; }

.clear-search {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    transition: color 0.3s ease;
    margin-left: 5px;
}

.clear-search:hover { color: #333; }

.search-results-info {
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
    color: #666;
    padding: 8px;
    background: #f0f7ff;
    border-radius: 8px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========================================== */
/* CARRUSEL DE SUBCATEGORÍAS */
/* ========================================== */
.app-subcategorias-container {
    position: relative;
    padding: 0 40px;
    margin-bottom: 20px;
    background-color: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
}

.app-subcategorias-carrusel {
    width: 100%;
    white-space: nowrap;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.app-subcategorias-carrusel::-webkit-scrollbar { display: none; }

.app-subcategoria-slide {
    display: inline-block;
    vertical-align: top;
    padding: 5px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease;
    width: 120px;
}

.app-subcategoria-slide:hover { transform: translateY(-3px); }

.app-subcategoria-slide.app-subcategoria-activa {
    background-color: #e8f4ff;
    border: 1px solid #0066cc;
    border-radius: 6px;
}

.app-subcategoria-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.app-subcategoria-imagen {
    width: 100px;
    height: 100px;
    margin: 0 auto 8px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.app-subcategoria-imagen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-subcategoria-nombre {
    font-size: 14px;
    margin: 5px 0;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
    margin-left: auto;
    margin-right: auto;
}

.app-subcategoria-contador {
    font-size: 12px;
    color: #666;
}

.app-nav-arrow {
    position: absolute;
    top: 40%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    z-index: 10;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background-color 0.3s;
}

.app-nav-arrow:hover { background-color: rgba(0, 0, 0, 0.8); }
.app-nav-prev { left: 5px; }
.app-nav-next { right: 5px; }

.app-custom-scrollbar-container {
    padding: 5px 0;
    width: 100%;
    margin-top: 10px;
}

.app-custom-scrollbar-track {
    height: 15px;
    background-color: #e0e0e0;
    border-radius: 8px;
    position: relative;
    cursor: pointer;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
}

.app-custom-scrollbar-thumb {
    height: 100%;
    background-color: #575757;
    border-radius: 8px;
    position: absolute;
    top: 0;
    left: 0;
    width: 20%;
    cursor: grab;
    background-image: linear-gradient(45deg, rgba(255,255,255,0.2) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.2) 75%, transparent 75%, transparent);
    background-size: 25px 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: background-color 0.2s ease;
}

.app-custom-scrollbar-thumb:hover,
.app-custom-scrollbar-thumb.active { background-color: #333; }
.app-custom-scrollbar-thumb.active { cursor: grabbing; }

/* ========================================== */
/* GRID DE PRODUCTOS */
/* ========================================== */
.productos-grid {
    margin-top: 10px;
    padding: 15px;
    background-color: #f7f7f7;
    border-radius: 10px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.productos-titulo {
    text-align: center;
    margin-bottom: 15px;
    font-size: 18px;
    color: #555;
}

.productos-contenido {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.producto-item {
    background: white;
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.producto-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.producto-item.hidden-by-search {
    display: none !important;
}

.producto-imagen {
    width: 100%;
    height: 0;
    padding-bottom: 100%;
    position: relative;
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 4px;
}

.producto-imagen img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.producto-nombre {
    font-size: 13px;
    margin: 5px 0;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.producto-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.producto-btn {
    width: 100%;
    text-align: center;
    font-size: 11px;
    padding: 8px;
    line-height: 1.2;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
}

.btn-view { background: #3B82F6; color: white; }
.btn-view:hover { background: #2563EB; }
.btn-download { background: #10B981; color: white; display: none; }
.btn-download:hover { background: #059669; }
.btn-download.downloaded { background: #6B7280; }

/* ========================================== */
/* PACK BADGE Y SELECTOR */
/* ========================================== */
.pack-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #F59E0B;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 10px;
    letter-spacing: 0.5px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.pack-selector {
    width: 100%;
    background: rgba(0,0,0,0.85);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    z-index: 100;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .pack-selector { flex-direction: column; align-items: stretch; overflow-x: visible; }
    .pack-selector-label { text-align: center; }
    .pack-selector-btn { text-align: center; }
}

.pack-selector-label { color: #ccc; font-size: 12px; white-space: nowrap; flex-shrink: 0; }

.pack-selector-btn {
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.pack-selector-btn:hover { background: rgba(255,255,255,0.3); }
.pack-selector-btn.active { background: #3B82F6; border-color: #3B82F6; font-weight: 700; }

/* ========================================== */
/* INDICADORES DE DESCARGA */
/* ========================================== */
.download-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(16,185,129,0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
}

.download-indicator svg { width: 18px; height: 18px; }

.download-progress {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 300px;
    max-width: 400px;
    z-index: 1000;
}

.progress-header { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: #374151; }

.progress-bar {
    width: 100%;
    height: 8px;
    background: #E5E7EB;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3B82F6, #10B981);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text { font-size: 12px; color: #6B7280; text-align: center; }

/* ========================================== */
/* TOAST NOTIFICATIONS */
/* ========================================== */
#toast-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
}

.toast {
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
    word-wrap: break-word;
}

.toast.success { background: rgba(16,185,129,0.95); }
.toast.error   { background: rgba(239,68,68,0.95); }
.toast.info    { background: rgba(59,130,246,0.95); }

@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}

/* ========================================== */
/* VISUALIZADOR */
/* ========================================== */
.fablab-viewer-view {
    padding: 0 !important;
    min-height: 100vh !important;
    overflow-y: auto;
    position: relative;
}

.back-to-library-btn {
    position: fixed;
    top: 20px;
    left: 100px;
    z-index: 1900;
    background: white;
    border: 2px solid #e0e0e0;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.back-to-library-btn:hover {
    background: #f0f0f0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.viewer-container {
    width: 100%;
    height: calc(100vh - 160px);
    position: relative;
    overflow: hidden;
}

.viewer-container.fullscreen-active {
    height: 100vh !important;
}

#viewer { width: 100%; height: 100%; }

@media (max-width: 768px) {
    .viewer-container:not(.fullscreen-active) { height: calc(100vh - 180px); }
}

@media (max-width: 480px) {
    .viewer-container:not(.fullscreen-active) { height: calc(100vh - 200px); }
}

.loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.98);
    padding: 32px 48px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    text-align: center;
    z-index: 9999;
}

.loading-overlay.hidden { display: none; }

.loading-spinner { text-align: center; padding: 40px; }

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

#loadingText { font-size: 15px; color: #333; font-weight: 500; }

/* ========================================== */
/* RESPONSIVE */
/* ========================================== */
@media (max-width: 1200px) { .productos-contenido { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 992px)  { .productos-contenido { grid-template-columns: repeat(4, 1fr); } }

@media (max-width: 768px) {
    .productos-contenido { grid-template-columns: repeat(3, 1fr); }
    .app-subcategoria-imagen { width: 80px; height: 80px; }
    .app-subcategoria-slide  { width: 100px; }
}

@media (max-width: 576px) {
    .productos-contenido { grid-template-columns: repeat(2, 1fr); }
    .biblioteca-titulo   { font-size: 20px; }
}

/* Borrado de conversiones propias (v6.7.2.0) */
.btn-delete-conv { flex: 0 0 auto; background: #fee2e2; border: 1px solid #fecaca; color: #b91c1c; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 14px; }
.btn-delete-conv:hover { background: #fecaca; }
