/* ============================================
   ?? MIS DIEZMOS - DISEÑO MODERNO
   ============================================ */
:root {
    --md-primary: #7c3aed;
    --md-primary-dark: #6d28d9;
    --md-primary-light: #a78bfa;
    --md-secondary: #10b981;
    --md-secondary-dark: #059669;
    --md-accent-1: #f59e0b;
    --md-accent-2: #3b82f6;
    --md-accent-3: #ec4899;
    --md-white: #ffffff;
    --md-gray: #64748b;
    --md-gray-light: #94a3b8;
    --md-gray-lighter: #cbd5e1;
    --md-bg: #f8fafc;
    --md-border: #e2e8f0;
    --md-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --md-shadow-md: 0 6px 16px rgba(0, 0, 0, 0.12);
    --md-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* ============================================
   ?? CONTENEDOR PRINCIPAL
   ============================================ */
.misdiezmos-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    background: var(--md-bg);
}

/* ============================================
   ?? ENCABEZADO
   ============================================ */
.misdiezmos-header {
    background: linear-gradient(135deg, var(--md-primary) 0%, var(--md-primary-dark) 100%);
    border-radius: 20px;
    padding: 2rem 2.5rem;
    box-shadow: var(--md-shadow-lg);
    margin-bottom: 2rem;
    animation: fadeInDown 0.6s ease-out;
}

.misdiezmos-header-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.misdiezmos-header-icon {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.misdiezmos-header-icon svg {
    width: 36px;
    height: 36px;
}

.misdiezmos-title {
    font-size: 2rem;
    font-weight: 800;
    color: white;
    margin: 0;
    letter-spacing: -0.5px;
}

/* ============================================
   ??? RADIO BUTTONS MODERNOS
   ============================================ */
.misdiezmos-radio-group {
    background: var(--md-white);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--md-shadow);
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease-out;
}

.misdiezmos-radio-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--md-gray);
    margin: 0 0 1.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.misdiezmos-radio-title svg {
    color: var(--md-primary);
}

.misdiezmos-radio-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.misdiezmos-radio-option {
    position: relative;
}

.misdiezmos-radio-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.misdiezmos-radio-label {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1.125rem 1.5rem;
    border: 2px solid var(--md-border);
    border-radius: 12px;
    background: var(--md-bg);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    color: var(--md-gray);
    font-size: 0.9375rem;
}

.misdiezmos-radio-label:hover {
    border-color: var(--md-primary-light);
    background: rgba(124, 58, 237, 0.05);
    transform: translateY(-2px);
}

.misdiezmos-radio-input:checked + .misdiezmos-radio-label {
    border-color: var(--md-primary);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(167, 139, 250, 0.1));
    color: var(--md-primary-dark);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.misdiezmos-radio-circle {
    width: 22px;
    height: 22px;
    border: 2px solid var(--md-gray-lighter);
    border-radius: 50%;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.misdiezmos-radio-input:checked + .misdiezmos-radio-label .misdiezmos-radio-circle {
    border-color: var(--md-primary);
    background: var(--md-primary);
    box-shadow: 0 0 0 2px white inset;
}

/* ============================================
   ?? SELECTOR DE PERIODO
   ============================================ */
.misdiezmos-periodo-card {
    background: var(--md-white);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: var(--md-shadow);
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.misdiezmos-periodo-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--md-primary-dark);
    margin: 0 0 1.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.misdiezmos-periodo-title svg {
    color: var(--md-primary);
    width: 24px;
    height: 24px;
}

.misdiezmos-periodo-select {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--md-gray);
    background: var(--md-bg);
    border: 2px solid var(--md-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%237c3aed' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 3rem;
}

.misdiezmos-periodo-select:hover {
    border-color: var(--md-primary-light);
    background-color: rgba(124, 58, 237, 0.03);
}

.misdiezmos-periodo-select:focus {
    outline: none;
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.misdiezmos-periodo-select option {
    padding: 0.75rem;
    font-weight: 600;
}

/* ============================================
   ?? TABLA DE DIEZMOS
   ============================================ */
.misdiezmos-table-card {
    background: var(--md-white);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--md-shadow);
    animation: fadeInUp 0.6s ease-out 0.2s both;
    overflow: hidden;
}

.misdiezmos-table-wrapper {
    overflow-x: auto;
    margin: 0 -1.5rem;
    padding: 0 1.5rem;
}

.misdiezmos-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9375rem;
}

.misdiezmos-table thead {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(167, 139, 250, 0.08));
    position: sticky;
    top: 0;
    z-index: 10;
}

.misdiezmos-table th {
    padding: 1.125rem 1rem;
    text-align: left;
    font-weight: 700;
    color: var(--md-primary-dark);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.misdiezmos-table th:first-child {
    border-top-left-radius: 12px;
    padding-left: 1.5rem;
}

.misdiezmos-table th:last-child {
    border-top-right-radius: 12px;
    padding-right: 1.5rem;
}

.misdiezmos-table tbody tr {
    border-bottom: 1px solid var(--md-border);
    transition: all 0.3s ease;
}

.misdiezmos-table tbody tr:hover {
    background: rgba(124, 58, 237, 0.03);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.misdiezmos-table tbody tr:last-child {
    border-bottom: none;
}

.misdiezmos-table td {
    padding: 1.125rem 1rem;
    color: var(--md-gray);
    white-space: nowrap;
}

.misdiezmos-table td:first-child {
    padding-left: 1.5rem;
    font-weight: 600;
    color: var(--md-primary-dark);
    /* ? PERMITIR AJUSTE DE NOMBRES LARGOS EN DESKTOP */
    max-width: 250px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.misdiezmos-table td:last-child {
    padding-right: 1.5rem;
}

/* Resaltar valores numéricos */
.misdiezmos-table td:not(:first-child) {
    font-weight: 600;
    color: var(--md-gray);
}

/* ============================================
   ? ESTADO DE CARGA
   ============================================ */
.misdiezmos-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1.5rem;
}

.misdiezmos-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--md-border);
    border-top-color: var(--md-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.misdiezmos-loading-text {
    font-size: 1.125rem;
    color: var(--md-gray);
    font-weight: 600;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   ?? ANIMACIONES
   ============================================ */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   ?? RESPONSIVE - TABLETS
   ============================================ */
@media (max-width: 1024px) {
    .misdiezmos-table th,
    .misdiezmos-table td {
        padding: 1rem 0.75rem;
        font-size: 0.875rem;
    }

    .misdiezmos-table th:first-child,
    .misdiezmos-table td:first-child {
        padding-left: 1rem;
    }

    .misdiezmos-table th:last-child,
    .misdiezmos-table td:last-child {
        padding-right: 1rem;
    }
}

@media (max-width: 768px) {
    .misdiezmos-container {
        padding: 1.5rem 1rem;
    }

    .misdiezmos-header {
        padding: 1.75rem 1.5rem;
        border-radius: 16px;
    }

    .misdiezmos-header-content {
        gap: 1rem;
    }

    .misdiezmos-header-icon {
        width: 60px;
        height: 60px;
    }

    .misdiezmos-header-icon svg {
        width: 30px;
        height: 30px;
    }

    .misdiezmos-title {
        font-size: 1.5rem;
    }

    .misdiezmos-radio-options {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .misdiezmos-radio-label {
        padding: 1rem 1.25rem;
    }

    .misdiezmos-periodo-card {
        padding: 1.5rem;
    }

    .misdiezmos-table-wrapper {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
}

/* ============================================
   ?? RESPONSIVE - MÓVILES
   ============================================ */
@media (max-width: 640px) {
    .misdiezmos-container {
        padding: 1rem 0.75rem;
    }

    .misdiezmos-header {
        padding: 1.5rem 1rem;
        margin-bottom: 1.5rem;
    }

    .misdiezmos-header-content {
        flex-direction: column;
        text-align: center;
    }

    .misdiezmos-title {
        font-size: 1.375rem;
    }

    .misdiezmos-radio-group {
        padding: 1rem;
    }

    .misdiezmos-radio-label {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }

    .misdiezmos-periodo-card {
        padding: 1.25rem;
    }

    .misdiezmos-periodo-title {
        font-size: 1.125rem;
    }

    .misdiezmos-table-card {
        padding: 1rem;
    }

    /* Tabla responsive en móviles - diseño de tarjetas */
    .misdiezmos-table thead {
        display: none;
    }

    .misdiezmos-table,
    .misdiezmos-table tbody,
    .misdiezmos-table tr,
    .misdiezmos-table td {
        display: block;
        width: 100%;
    }

    .misdiezmos-table tr {
        margin-bottom: 1rem;
        border: 2px solid var(--md-border);
        border-radius: 12px;
        padding: 1rem;
        background: var(--md-white);
        position: relative;
    }

    /* ?? BARRA LATERAL DE COLOR */
    .misdiezmos-table tr::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 5px;
        background: linear-gradient(180deg, var(--md-primary), var(--md-primary-dark));
        border-radius: 12px 0 0 12px;
    }

    .misdiezmos-table tr:hover {
        box-shadow: var(--md-shadow);
    }

    .misdiezmos-table td {
        padding: 0.75rem 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
    }

    /* ?? NOMBRE - PRIMERA CELDA CON MANEJO ESPECIAL */
    .misdiezmos-table td:first-child {
        padding-top: 0;
        padding-left: 0;
        font-weight: 800;
        font-size: 1.125rem;
        color: var(--md-primary-dark);
        padding-bottom: 1rem;
        border-bottom: 2px solid var(--md-border);
        margin-bottom: 0.75rem;
        /* ? PERMITIR MÚLTIPLES LÍNEAS PARA NOMBRES LARGOS */
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.4;
        display: block; /* Cambiar a block para que ocupe todo el ancho */
        text-align: left;
    }

    .misdiezmos-table td:last-child {
        padding-bottom: 0;
        padding-right: 0;
    }

    /* ?? LABELS CON DATOS */
    .misdiezmos-table td:not(:first-child)::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.8125rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--md-primary-dark);
        flex-shrink: 0;
        min-width: 100px;
    }

    .misdiezmos-table td:not(:first-child) {
        font-weight: 700;
        color: #1e293b;
        font-size: 0.9375rem;
        white-space: normal;
    }
}

/* ============================================
   ?? ACCESIBILIDAD
   ============================================ */
.misdiezmos-radio-input:focus + .misdiezmos-radio-label,
.misdiezmos-periodo-select:focus {
    outline: 3px solid var(--md-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   ?? TEMA OSCURO (OPCIONAL)
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --md-bg: #0f172a;
        --md-white: #1e293b;
        --md-gray: #cbd5e1;
        --md-gray-light: #94a3b8;
        --md-border: #334155;
    }

    .misdiezmos-table tbody tr:hover {
        background: rgba(124, 58, 237, 0.1);
    }
}
