/* 
   SISTEMA DE DISEÑO PREMIUM (Colección de Dedales)
   Estilo: Mobile-First, Minimalista y Elegante
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Paleta de Colores Harmónica (Azul Pizarra y Gris Sofisticado) */
    --primary: #475569;        /* Slate Blue */
    --primary-light: #64748b;
    --primary-dark: #334155;
    --accent: #0ea5e9;         /* Sky Blue */
    --accent-sage: #84a98c;    /* Sage Green */
    --background: #f8fafc;     /* Off-White */
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;           /* Gris oscuro */
    --text-muted: #64748b;     /* Gris medio */
    --error: #ef4444;
    --success: #10b981;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset de estilos */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Evitar barra de desplazamiento horizontal por elementos off-canvas */
}

/* Tipografía */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--primary-dark);
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

/* Contenedor Principal */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header Premium */
header.app-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    transition: var(--transition);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.brand-icon {
    color: var(--accent-sage);
    stroke-width: 2.5;
    flex-shrink: 0;
}

.brand-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-dark);
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--transition);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Botones Premium */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-only {
    padding: 8px;
    border-radius: 50%;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background-color: var(--background);
    border-color: var(--primary-light);
}

.btn-accent {
    background-color: var(--accent-sage);
    color: white;
}

.btn-accent:hover {
    background-color: #6a8c71;
}

.btn-danger {
    background-color: var(--error);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

/* Grid y tarjetas de dedales - Diseñadas para móviles */
main.app-content {
    flex: 1;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: 100%; /* Por defecto móvil 100% */
    gap: 20px;
    margin-top: 16px;
}

/* Tarjeta de Dedal Premium */
.dedal-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
}

.dedal-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.badge-visibilidad {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 10;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.badge-visibilidad.privado {
    background-color: rgba(239, 68, 68, 0.9);
    color: white;
}

.badge-visibilidad.publico {
    background-color: rgba(16, 185, 129, 0.9);
    color: white;
}

.dedal-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #f1f5f9;
    overflow: hidden;
}

.dedal-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.dedal-card:hover .dedal-image {
    transform: scale(1.03);
}

/* Reproductor de vídeo embebido */
.dedal-video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #000;
}

.dedal-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dedal-card-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dedal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dedal-public-id {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.dedal-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.meta-icon {
    color: var(--primary-light);
    stroke-width: 2;
}

.dedal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.tag {
    background-color: #f1f5f9;
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.tag:hover {
    background-color: var(--border);
}

/* Panel de Filtros Off-canvas */
.filters-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 320px;
    height: 100%;
    height: 100dvh; /* Altura dinámica en móviles para evitar ocultamiento por barras del navegador */
    background-color: var(--surface);
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.35s;
    display: flex;
    flex-direction: column;
    visibility: hidden; /* Evitar barra de desplazamiento horizontal e interacción cuando está oculto */
}

.filters-sidebar.active {
    right: 0;
    visibility: visible;
}

.filters-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.filters-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.filters-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Inputs y Selects */
.input-control {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--background);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    transition: var(--transition);
}

.input-control:focus {
    outline: none;
    border-color: var(--accent-sage);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px rgba(132, 169, 140, 0.2);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
    padding: 4px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    accent-color: var(--accent-sage);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Overlay de Fondo */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Barra de Búsqueda Integrada */
.search-container {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-input-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input-wrapper .input-control {
    padding-left: 36px;
}

/* Animaciones */
.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Vista Detallada de Dedal */
.detail-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.detail-multimedia-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-info {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-title-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

.detail-features-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 12px;
}

.feature-info-card {
    background-color: var(--background);
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.feature-info-icon-wrapper {
    background-color: var(--surface);
    padding: 8px;
    border-radius: 50%;
    color: var(--accent-sage);
}

.feature-info-content h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.feature-info-content p {
    font-size: 1rem;
    font-weight: 600;
}

/* Vista de Login Premium */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 0;
}

.login-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-header h2 {
    font-size: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.login-toggle {
    margin-top: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.login-toggle a {
    color: var(--accent-sage);
    font-weight: 600;
}

/* Dashboard de Admin y Colaborador */
.dashboard-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.table-wrapper {
    overflow-x: auto;
    background-color: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.admin-table th, table.admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.admin-table th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: var(--primary-dark);
}

table.admin-table tr:hover {
    background-color: #f8fafc;
}

.table-thumbnail {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 4px;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Sección de Características Dinámicas */
.features-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.feature-group-card {
    background-color: var(--surface);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.feature-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.feature-values-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.value-pill {
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.value-pill button {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    padding: 0;
}

/* Sección de Encuestas y Votaciones */
.surveys-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.survey-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
}

.survey-meta {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.survey-options-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.survey-option-label {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--background);
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.survey-option-label:hover {
    border-color: var(--accent-sage);
    background-color: #f4f7f5;
}

.survey-option-label input[type="radio"] {
    accent-color: var(--accent-sage);
    width: 20px;
    height: 20px;
}

/* Resultados de Encuestas */
.survey-results {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-bar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
}

.result-bar-outer {
    background-color: var(--border);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}

.result-bar-inner {
    background-color: var(--accent-sage);
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease-out;
}

.survey-voted-badge {
    color: var(--success);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 12px;
}

/* Estadísticas Premium */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.stats-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.stats-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.stats-list-item:last-child {
    border-bottom: none;
}

/* Pie de página (Footer) */
footer.app-footer {
    text-align: center;
    padding: 24px 16px;
    border-top: 1px solid var(--border);
    background-color: var(--surface);
    font-size: 0.8rem;
    color: var(--text-muted);
}

footer .version {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 4px;
    font-family: monospace;
}

/* Error Container */
.error-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 0;
}

.error-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 32px;
    text-align: center;
    max-width: 480px;
    box-shadow: var(--shadow);
}

.error-icon-wrapper {
    background-color: #fee2e2;
    color: var(--error);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.error-icon {
    width: 32px;
    height: 32px;
}

.error-message {
    color: var(--text-muted);
    margin: 8px 0 24px;
}

/* Formulario Crear/Editar Dedal */
.form-card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
    box-shadow: var(--shadow);
}

.file-preview-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 8px;
}

.file-preview-box {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 8px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--background);
    overflow: hidden;
}

.file-preview-box img, .file-preview-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: calc(var(--radius) - 4px);
}

/* Media Queries para Tabletas y Escritorio */
@media (min-width: 640px) {
    .brand-title {
        font-size: 1.15rem;
        max-width: none;
        white-space: normal;
        overflow: visible;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .detail-features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
    
    .features-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .file-preview-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Barra de Filtros Activos */
.active-filters-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

@media (min-width: 600px) {
    .active-filters-container {
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }
}

.active-filters-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.active-filters-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #f1f5f9;
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.8rem;
    color: var(--text);
    transition: var(--transition);
}

.filter-chip:hover {
    background-color: var(--border);
}

.filter-chip-label {
    font-weight: 600;
    color: var(--primary-light);
}

.filter-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    transition: var(--transition);
}

.filter-chip-remove:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.filter-chip-remove i {
    width: 12px;
    height: 12px;
}

.btn-clear-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--error);
    background-color: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.15);
    cursor: pointer;
    transition: var(--transition);
    margin-left: auto;
}

.btn-clear-all:hover {
    background-color: var(--error);
    color: white;
    border-color: var(--error);
    transform: translateY(-1px);
}

.btn-clear-all i {
    width: 14px;
    height: 14px;
}

/* Enlaces de Etiquetas (Tags) Filtrables */
.tag-link {
    display: inline-flex;
    text-decoration: none;
}

.tag-link:hover .tag {
    background-color: var(--accent-sage);
    color: white;
    border-color: var(--accent-sage);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Modal Lightbox para Foto Completa */
.photo-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background-color: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.photo-modal.active {
    display: flex;
    opacity: 1;
}

.photo-modal-content {
    max-width: 90%;
    max-height: 85%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.photo-modal.active .photo-modal-content {
    transform: scale(1);
}

.photo-modal-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.photo-modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    z-index: 2001;
}

.photo-modal-close:hover {
    background: var(--error);
    transform: rotate(90deg);
}

.photo-modal-close i {
    width: 24px;
    height: 24px;
}

/* Scrollbar Premium para Listas de Estadísticas */
.stats-list {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* Para motores WebKit (Chrome, Safari, Edge) */
.stats-list::-webkit-scrollbar {
    width: 6px;
}

.stats-list::-webkit-scrollbar-track {
    background: transparent;
}

.stats-list::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 20px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.stats-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-light);
}

/* ==========================================================================
   COMPONENTES PREMIUM: SELECT PERSONALIZADO Y BUSCADORES DE FILTROS
   ========================================================================== */

/* Contenedor del Selector Personalizado */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

/* Gatillo o Botón Desplegable */
.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--background);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.custom-select-trigger:hover {
    background-color: var(--surface);
    border-color: var(--primary-light);
}

.custom-select-wrapper.open .custom-select-trigger {
    outline: none;
    border-color: var(--accent-sage);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px rgba(132, 169, 140, 0.2);
}

.custom-select-trigger span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
}

.custom-select-trigger .chevron {
    transition: transform 0.3s ease;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.custom-select-wrapper.open .custom-select-trigger .chevron {
    transform: rotate(180deg);
}

/* Panel Desplegable Flotante */
.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1100;
    display: none;
    flex-direction: column;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.custom-select-wrapper.open .custom-select-dropdown {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Buscador Interno del Desplegable */
.custom-select-search-wrapper {
    position: relative;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.custom-select-search-wrapper .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 14px;
    height: 14px;
    pointer-events: none;
}

.custom-select-search {
    width: 100%;
    padding: 6px 30px 6px 28px;
    font-size: 0.85rem;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--background);
    color: var(--text);
    font-family: inherit;
    transition: var(--transition);
}

.custom-select-search:focus {
    outline: none;
    border-color: var(--accent-sage);
    background-color: var(--surface);
    box-shadow: 0 0 0 2px rgba(132, 169, 140, 0.25);
}

.btn-clear-custom-search {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-muted);
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border-radius: 50%;
}

.btn-clear-custom-search:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.btn-clear-custom-search i {
    width: 12px;
    height: 12px;
}

/* Lista de Opciones */
.custom-select-options {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.custom-select-options::-webkit-scrollbar {
    width: 6px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: transparent;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 20px;
    border: 1px solid transparent;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-light);
}

.custom-select-options li {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.custom-select-options li:hover {
    background-color: #f1f5f9;
    color: var(--primary-dark);
}

.custom-select-options li.selected {
    background-color: #f4f7f5;
    color: var(--accent-sage);
    font-weight: 600;
}

.custom-select-options li.no-matches {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
    background-color: transparent !important;
}

/* Buscador de Características Local */
.local-feature-search {
    margin-bottom: 8px;
    position: relative;
}

.local-feature-search .input-filter-features {
    padding: 4px 24px 4px 8px;
    font-size: 0.8rem;
    height: 30px;
    background-color: var(--surface);
    width: 100%;
}

.btn-clear-local-filter {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-muted);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    transition: var(--transition);
}

.btn-clear-local-filter:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.btn-clear-local-filter i {
    width: 12px;
    height: 12px;
}

/* Visibilidad de Contraseñas (Botón de Ojo) */
.btn-toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border-radius: 50%;
    z-index: 10;
}

.btn-toggle-password:hover {
    background-color: #e2e8f0;
    color: var(--primary-dark);
}

.btn-toggle-password i {
    width: 18px;
    height: 18px;
}

/* Espaciado derecho automático para inputs de tipo password que tengan un botón toggle */
.form-group div[style*="position: relative"] input[type="password"],
.form-group div[style*="position: relative"] input[type="text"].password-visible {
    padding-right: 42px !important;
}

/* Estilos de Contenedor de Mapa de Leaflet interactivo */
#map-container-wrapper {
    transition: all 0.3s ease-out;
}

#map-container-wrapper.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 9999 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    transform: none !important;
    animation: none !important;
}

#map-container-wrapper.fullscreen #origins-map {
    height: 100% !important;
}

#origins-map {
    z-index: 10;
}

/* Corrección de estilos de Leaflet para armonizar con el tema premium */
.leaflet-container {
    font-family: inherit !important;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow) !important;
    border: 1px solid var(--border);
}

.leaflet-popup-content {
    margin: 8px 12px !important;
    font-size: 0.85rem !important;
    color: var(--text);
}

.leaflet-popup-tip {
    box-shadow: var(--shadow) !important;
}

/* Desactivar transformaciones que rompen el "position: fixed" de la pantalla completa del mapa */
body.map-fullscreen main.app-content {
    transform: none !important;
    animation: none !important;
}

body.map-fullscreen {
    overflow: hidden !important;
}
