/* ========================================
   1. VARIABLES Y CONFIGURACIÓN GENERAL
======================================== */

:root {
    --color-primary: #c8102e;
    --color-primary-hover: #a90d26;
    --color-primary-light: #fff0f2;

    --color-sidebar: #202938;
    --color-sidebar-hover: #303c4e;

    --color-background: #f5f6f8;
    --color-surface: #ffffff;

    --color-text: #202938;
    --color-text-secondary: #7b8493;
    --color-border: #e8ebef;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--color-background);
    color: var(--color-text);
    font-size: 14px;
}

button {
    font: inherit;
    cursor: pointer;
    border: none;
}


/* ========================================
   2. ESTRUCTURA PRINCIPAL
======================================== */

.app-container {
    display: flex;
    min-height: 100vh;
}


/* ========================================
   3. MENÚ LATERAL
======================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;

    z-index: 100;

    display: flex;
    flex-direction: column;

    width: var(--sidebar-width);

    background: var(--color-sidebar);
    color: #ffffff;
}


/* LOGOTIPO */

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 25px 22px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;

    background: var(--color-primary);
    border-radius: 11px;

    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
}

.brand h2 {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -0.3px;
}

.brand span {
    display: block;
    margin-top: 4px;

    color: #aeb8c6;
    font-size: 11px;
}


/* NAVEGACIÓN */

.sidebar-nav {
    flex: 1;
    padding: 25px 14px;
}

.nav-section-title {
    display: block;

    padding: 0 11px;
    margin: 17px 0 9px;

    color: #8995a5;

    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-section-title:first-child {
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;

    width: 100%;
    padding: 11px 12px;
    margin-bottom: 4px;

    background: transparent;
    border-radius: var(--radius-sm);

    color: #c2cbd6;
    text-align: left;
    font-size: 13px;

    transition: background 0.2s, color 0.2s;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: #ffffff;
}

.nav-item.active {
    background: var(--color-primary);
    color: #ffffff;
    font-weight: 600;
}

.nav-icon {
    width: 19px;
    text-align: center;
    font-size: 17px;
}


/* PIE DEL MENÚ */

.sidebar-footer {
    padding: 18px 22px;

    border-top: 1px solid rgba(255, 255, 255, 0.08);

    color: #aeb8c6;
    font-size: 11px;
}

.sidebar-footer small {
    display: block;
    margin-top: 5px;
    color: #758194;
}


/* ========================================
   4. CONTENIDO PRINCIPAL
======================================== */

.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
}


/* ========================================
   5. CABECERA SUPERIOR
======================================== */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    height: 75px;
    padding: 0 35px;

    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 11px;

    color: var(--color-text-secondary);
    font-size: 13px;
}

.breadcrumb strong {
    color: var(--color-text);
    font-weight: 600;
}

.breadcrumb-separator {
    color: #c5cad2;
}


/* USUARIO */

.topbar-user {
    display: flex;
    align-items: center;
    gap: 11px;
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 37px;
    height: 37px;

    background: var(--color-primary-light);
    color: var(--color-primary);

    border-radius: 50%;
    font-weight: 700;
}

.user-info strong {
    display: block;
    font-size: 12px;
}

.user-info span {
    display: block;
    margin-top: 3px;

    color: var(--color-text-secondary);
    font-size: 11px;
}


/* BOTÓN Y ESCUDO MÓVIL */

.menu-toggle,
.mobile-logo {
    display: none;
}

.menu-toggle {
    background: transparent;
    color: var(--color-text);
    font-size: 25px;
    padding: 5px 10px;
}


/* ========================================
   6. ÁREA DE TRABAJO
======================================== */

.page-content {
    padding: 35px;
}


/* ========================================
   7. TARJETA DE BIENVENIDA
======================================== */

.welcome-card {
    padding: 32px;

    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);

    box-shadow: 0 3px 12px rgba(20, 30, 45, 0.025);
}

.welcome-card h2 {
    margin-bottom: 10px;

    font-size: 18px;
    font-weight: 650;
}

.welcome-card p {
    max-width: 550px;

    color: var(--color-text-secondary);
    line-height: 1.7;
    font-size: 13px;
}

.primary-button {
    margin-top: 23px;
    padding: 11px 17px;

    background: var(--color-primary);
    color: #ffffff;

    border-radius: var(--radius-sm);

    font-size: 12px;
    font-weight: 600;

    transition: background 0.2s, transform 0.2s;
}

.primary-button:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}


/* ========================================
   8. MENÚ LATERAL DESPLEGABLE
======================================== */

.sidebar-overlay {
    display: none;
}


/* ========================================
   9. TABLETS Y MÓVILES
======================================== */

@media (max-width: 768px),
(hover: none) and (pointer: coarse) {

    /* CABECERA */

    .topbar {
        height: 65px;
        padding: 0 18px;
    }

    .topbar-left {
        gap: 8px;
    }

    .menu-toggle {
        display: block;
    }

    .mobile-logo {
        display: flex;
        align-items: center;
        justify-content: center;

        flex-shrink: 0;

        width: 38px;
        height: 38px;

        background: var(--color-primary);
        color: #ffffff;

        border-radius: 9px;

        font-size: 15px;
        font-weight: 800;
    }


    /* MENÚ LATERAL */

    .sidebar {
        width: 260px;

        transform: translateX(-100%);
        transition: transform 0.25s ease;

        z-index: 1001;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-header {
        padding: 20px 14px;
    }

    .brand h2 {
        font-size: 12px;
    }

    .sidebar-nav {
        padding: 20px 9px;
    }

    .nav-item {
        justify-content: flex-start;
        gap: 8px;

        padding: 11px 9px;

        font-size: 12px;
    }


    /* FONDO DEL MENÚ */

    .sidebar-overlay {
        position: fixed;
        inset: 0;

        display: none;

        background: rgba(0, 0, 0, 0.45);
        z-index: 1000;
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }


    /* CONTENIDO */

    .main-content {
        width: 100%;
        margin-left: 0;
    }

    .page-content {
        padding: 22px 18px;
    }

}


/* ========================================
   10. MÓVILES PEQUEÑOS
======================================== */

@media (max-width: 520px) {

    .topbar {
        padding: 0 12px;
    }

    .user-info {
        display: none;
    }

    .page-content {
        padding: 20px 12px;
    }

    .welcome-card {
        padding: 22px 17px;
    }

}



/* ========================================
   11. PANTALLA DE SOCIOS
======================================== */

.socios-page {
    width: 100%;
}


/* PESTAÑAS */

.socios-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;

    padding: 5px;
    margin-bottom: 25px;

    background: #eceef2;
    border-radius: 11px;
}

.socios-tab {
    padding: 9px 22px;

    background: transparent;
    border-radius: 8px;

    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 550;

    transition: all 0.2s ease;
}

.socios-tab:hover {
    color: var(--color-text);
}

.socios-tab.active {
    background: var(--color-primary);
    color: var(--color-background);
    font-weight: 650;

    box-shadow: 0 2px 5px rgba(20, 30, 45, 0.07);
}


/* BUSCADOR */

.socios-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    flex-wrap: wrap;

    position: relative;
    margin-bottom: 22px;
}

.socios-search {
    display: flex;
    align-items: center;

    width: 100%;
    max-width: 680px;
    min-height: 48px;

    padding: 0 5px;

    background: #ffffff;
    border: 1px solid #e5e8ed;
    border-radius: 11px;

    box-shadow: 0 2px 8px rgba(20, 30, 45, 0.025);

    transition: border-color 0.2s, box-shadow 0.2s;
}

.socios-search:focus-within {
    border-color: rgba(200, 16, 46, 0.45);
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.06);
}

.search-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 48px;
    flex-shrink: 0;

    color: #929baa;
    font-size: 22px;
    line-height: 1;
}

.socios-search select {
    max-width: 190px;
    height: 34px;

    padding: 0 12px;

    background: #f5f6f8;
    border: none;
    border-radius: 7px;
    outline: none;

    color: #465163;
    font-family: inherit;
    font-size: 11px;
    font-weight: 550;

    cursor: pointer;
}

.socios-search input {
    flex: 1;
    min-width: 0;
    height: 44px;

    padding: 0 15px;

    background: transparent;
    border: none;
    outline: none;

    color: var(--color-text);
    font-family: inherit;
    font-size: 12px;
}

.socios-search input::placeholder {
    color: #a0a7b2;
}

/* Alineación de la lupa */
.socios-search .search-icon {
    align-self: center;
    transform: translateY(-3px);
}

/* Alineación de la X en ordenador */
.socios-search .clear-search-button {
    align-self: center;
    transform: translateY(-1px);
}

.clear-search-button {
    border: none;
    background: transparent;
    color: #888;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 5px 12px;
    flex-shrink: 0;
}

.clear-search-button:hover {
    color: #333;
}

.clear-search-button[hidden] {
    display: none;
}


/* CONTENEDOR DEL FUTURO LISTADO */

.socios-table-container {
    min-height: 250px;

    background: #ffffff;
    border: 1px solid #eaedf1;
    border-radius: 13px;

    box-shadow: 0 2px 10px rgba(20, 30, 45, 0.025);
}

.socios-empty-message {
    padding: 55px 20px;

    color: var(--color-text-secondary);
    font-size: 12px;
    text-align: center;
}


/* ADAPTACIÓN A MÓVILES */

@media (max-width: 520px) {

    .socios-tabs {
        width: 100%;
    }

    .socios-tab {
        flex: 1;
        padding: 10px;
    }

    .socios-search {
        flex-wrap: nowrap;
        padding: 0 5px;
        min-height: 46px;
    }

    .search-icon {
        height: 46px;
    }

    .socios-search input {
        flex: 1;
        min-width: 0;
        width: 100%;
    }

    .socios-search select {
        max-width: calc(100% - 42px);
        width: 100%;
    }

    .socios-search input {
        flex-basis: 100%;
        padding-left: 10px;
    }

    .socios-search .search-icon {
        transform: translateY(0);
    }

}


/* ========================================
   12. FILTROS AVANZADOS
======================================== */


.advanced-filters-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;

    min-height: 48px;
    padding: 0 17px;

    background: #ffffff;
    border: 1px solid #e5e8ed;
    border-radius: 11px;

    color: #465163;
    font-size: 12px;
    font-weight: 550;

    box-shadow: 0 2px 8px rgba(20, 30, 45, 0.025);
    transition: all 0.2s ease;
}

.advanced-filters-button:hover,
.advanced-filters-button.active {
    border-color: rgba(200, 16, 46, 0.4);
    color: var(--color-primary);
}

.advanced-filters-button>span:first-child {
    font-size: 18px;
}

.filter-chevron {
    font-size: 16px;
    transition: transform 0.2s;
}

.advanced-filters-button.active .filter-chevron {
    transform: rotate(180deg);
}


/* PANEL */

.advanced-filters-panel {
    width: 100%;
    flex-basis: 100%;
    flex-shrink: 0;

    padding: 22px;

    background: #ffffff;
    border: 1px solid #e8ebef;
    border-radius: 13px;

    box-shadow: 0 8px 25px rgba(20, 30, 45, 0.07);
}

.advanced-filters-panel[hidden] {
    display: none;
}

.advanced-filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    margin-bottom: 18px;
}

.advanced-filters-header h3 {
    font-size: 14px;
    font-weight: 650;
}

.advanced-filters-header p {
    margin-top: 5px;

    color: var(--color-text-secondary);
    font-size: 11px;
}

.clear-filters-button {
    padding: 8px 11px;

    background: var(--color-primary);
    border-radius: 7px;

    color: var(--color-background);
    font-size: 11px;
    font-weight: 600;
}

.clear-filters-button:hover {
    background: #ffe1e6;
}


/* LISTADO DE FILTROS */

.advanced-filters-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.advanced-filter {
    min-width: 0;

    border: 1px solid #e9ecf0;
    border-radius: 9px;

    transition: border-color 0.2s, background 0.2s;
}

.advanced-filter[open],
.advanced-filter.enabled {
    border-color: rgba(200, 16, 46, 0.25);
}

.advanced-filter summary {
    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: 43px;
    padding: 0 12px;

    list-style: none;
    cursor: pointer;
}

.advanced-filter summary::-webkit-details-marker {
    display: none;
}

.filter-enable-label {
    display: flex;
    align-items: center;
    gap: 10px;

    color: #465163;
    font-size: 12px;
    cursor: pointer;
}

.filter-enable {
    width: 15px;
    height: 15px;

    accent-color: var(--color-primary);
    cursor: pointer;
}

.advanced-filter.enabled summary {
    background: #fff9fa;
}

.advanced-filter.enabled .filter-enable-label {
    color: var(--color-primary);
    font-weight: 600;
}

.filter-item-chevron {
    color: #929baa;
    font-size: 15px;
    transition: transform 0.2s;
}

.advanced-filter[open] .filter-item-chevron {
    transform: rotate(180deg);
}


/* CONTROLES */

.filter-control {
    padding: 12px;
    border-top: 1px solid #edf0f3;
}

.filter-control-input {
    width: 100%;
    min-width: 0;
    height: 36px;

    padding: 0 10px;

    background: #f8f9fb;
    border: 1px solid #e5e8ed;
    border-radius: 7px;

    color: var(--color-text);
    font-family: inherit;
    font-size: 11px;
}

.filter-control-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.filter-control-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.filter-date-fields,
.filter-range-fields {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-date-fields {
    flex-direction: column;
    align-items: stretch;
}

.filter-range-fields span,
.date-range-fields span {
    flex-shrink: 0;

    color: var(--color-text-secondary);
    font-size: 10px;
}

.date-range-fields {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.date-range-fields[hidden],
.date-exact[hidden] {
    display: none;
}

.date-range-fields input {
    flex: 1;
}


/* ADAPTACIÓN A TABLETS Y MÓVILES */

@media (max-width: 768px) {

    .advanced-filters-list {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 520px) {

    .socios-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .advanced-filters-button {
        width: 100%;
    }

    .advanced-filters-panel {
        padding: 15px;
    }

    .advanced-filters-header {
        align-items: flex-start;
    }

    .filter-range-fields,
    .date-range-fields {
        flex-wrap: wrap;
    }

}

/* OPCIONES DE FILTRO DE FECHA */

.filter-date-options {
    display: flex;
    gap: 7px;
    margin-bottom: 12px;
}

.date-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    flex: 1;
    padding: 9px 5px;

    background: #f5f6f8;
    border: 1px solid #e8ebef;
    border-radius: 7px;

    color: #687386;
    font-size: 11px;
    cursor: pointer;
}

.date-option.active {
    background: var(--color-primary-light);
    border-color: rgba(200, 16, 46, 0.25);
    color: var(--color-primary);
    font-weight: 600;
}

.date-option input {
    accent-color: var(--color-primary);
}


/* COLUMNAS VISIBLES */

.visible-columns-panel {
    width: 100%;
    flex-basis: 100%;
}

.visible-columns-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px 16px;
    margin-top: 18px;
}

.visible-column-option {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;

    background: #ffffff;
    border: 1px solid #edf0f3;
    border-radius: 9px;

    color: #465163;
    font-size: 13px;
    cursor: pointer;

    transition: background 0.2s, border-color 0.2s;
}

.visible-column-option:hover {
    background: #f8f9fb;
    border-color: #dce1e8;
}

.visible-column-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #b3132b;
    cursor: pointer;
}

@media (max-width: 520px) {
    .visible-columns-list {
        grid-template-columns: 1fr;
    }
}




/* ========================================
   TABLA DE SOCIOS
======================================== */

.socios-table-container {
    min-width: 0;
    min-height: 0;
    overflow: hidden;

    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}

/* Zona desplazable de la tabla */

.socios-table-scroll {
    width: 100%;
    max-height: 65vh;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

/* Tabla */

.socios-table {
    width: 100%;
    min-width: max-content;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--color-text);
    font-size: 13px;
}

/* Cabecera */

.socios-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.socios-table th {
    padding: 15px 18px;
    background: var(--color-text);
    color: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Celdas */

.socios-table td {
    padding: 14px 18px;
    border-bottom: 1px solid #f0f1f3;
    white-space: nowrap;
    vertical-align: middle;
    transition: background 0.15s ease;
    text-align: center;
}

/* Filas */

.socios-table tbody tr {
    background: #ffffff;
    transition: background 0.15s ease;
}

.socios-table tbody tr:hover {
    background: var(--color-border);
}

.socios-table tbody tr:last-child td {
    border-bottom: none;
}

/* Contador de resultados */

.socios-table-count {
    margin: 0 4px 12px;
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 500;
}

/* Mensajes de tabla vacía */

.socios-empty-message {
    padding: 35px 20px;
    margin: 0;
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: 13px;
    text-align: center;
}

/* ========================================
   TABLA RESPONSIVE
======================================== */

@media (max-width: 768px) {

    .socios-table-scroll {
        max-height: 60vh;
        border-radius: var(--radius-sm);
    }

    .socios-table {
        font-size: 12px;
    }

    .socios-table th {
        padding: 13px 14px;
        font-size: 10px;
    }

    .socios-table td {
        padding: 12px 14px;
    }

    .socios-table-count {
        margin-top: 10px;
    }

}

@media (max-width: 520px) {

    .socios-table-scroll {
        max-height: 55vh;
    }

    .socios-table th,
    .socios-table td {
        padding: 11px 12px;
    }

}


/* ------------------------------------------
   ORDENACIÓN DE COLUMNAS DE LA TABLA
------------------------------------------ */

.socios-table th.sortable-column {
    cursor: pointer;
    user-select: none;
}

.sortable-column-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.sort-indicator {
    display: inline-block;
    font-size: 0.85em;
    opacity: 0.35;
    transition: opacity 0.15s ease;
}

.socios-table th.sortable-column:hover .sort-indicator {
    opacity: 0.8;
}

.socios-table th.sortable-column.sorted .sort-indicator {
    opacity: 1;
    font-weight: 700;
}

.socios-table th.sortable-column:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -3px;
}