/* admin.css - Estilos para Historial, Inventario y Analytics */

/* --- TABLAS RESPONSIVAS (MODO CARD) --- */
@media (max-width: 768px) {
    .admin-table thead {
        display: none; /* Escondemos cabeceras en móvil */
    }

    .admin-table, 
    .admin-table tbody, 
    .admin-table tr, 
    .admin-table td {
        display: block;
        width: 100%;
    }

    .admin-table tr {
        background: white;
        border: 1px solid var(--border);
        border-radius: 16px;
        padding: 15px;
        margin-bottom: 15px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    }

    .admin-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 8px 0;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.9rem;
    }

    .admin-table td:last-child {
        border-bottom: none;
        padding-top: 15px;
        justify-content: center;
    }

    .admin-table td::before {
        content: attr(data-label);
        float: left;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.7rem;
        letter-spacing: 0.05em;
    }

    /* Ajustes específicos para botones de acción en card */
    .actions-cell {
        background: var(--bg-app);
        margin: 10px -15px -15px -15px;
        padding: 15px !important;
        border-radius: 0 0 16px 16px;
    }
}

/* --- TABLAS DE DATOS --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

.data-table th, .data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.85rem;
}

@media (min-width: 1024px) {
    .data-table { min-width: 100%; }
    .data-table th, .data-table td { padding: 16px 24px; }
}

/* Alineamos a la derecha: Método, Artículos, Total y Acción */
.data-table th:nth-child(3), .data-table td:nth-child(3),
.data-table th:nth-child(4), .data-table td:nth-child(4),
.data-table th:nth-child(5), .data-table td:nth-child(5),
.data-table th:nth-child(6), .data-table td:nth-child(6) {
    text-align: right;
}

/* --- TABS Y FILTROS PREMIUM --- */
.analytics-tabs {
    display: flex;
    gap: 30px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: color 0.3s;
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
}

.quick-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-pill {
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-pill.active {
    background: #ffe4e6; /* Rosa Nomimi */
    border-color: var(--primary);
    color: var(--primary);
}

.tab-content {
    display: none;
    animation: fadeInTab 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* --- HEATMAP (MAPA DE CALOR CSS GRID) --- */
.heatmap-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.heatmap-header {
    display: grid;
    grid-template-columns: 45px repeat(7, 1fr);
    font-size: 0.70rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.heatmap-row {
    display: grid;
    grid-template-columns: 45px repeat(7, 1fr);
    min-height: 28px;
    margin-bottom: 2px;
}

.heatmap-y-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
}

.heatmap-cell {
    border: 1px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    transition: transform 0.2s;
    border-radius: 2px;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* --- ANALYTICS --- */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.value { font-size: 2.2rem; font-weight: 700; }

.charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) { .charts-container { grid-template-columns: 1fr 1fr; } }

.chart-box {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    height: 300px;
}

/* --- GESTIÓN DE INVENTARIO (EDICIÓN) --- */
.modifier-group-card {
    background: #fffdfb;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
}

.group-header .g-name {
    font-weight: 700;
    font-size: 1rem;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    padding: 4px 0;
    transition: all 0.2s;
    width: 100%;
}

.group-header .g-name:focus {
    border-bottom-color: var(--accent);
    outline: none;
}

.modifier-option-row, .variant-edit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.modifier-option-row:hover, .variant-edit-row:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.modifier-option-row input[type="text"], .variant-edit-row input[type="text"] {
    flex: 1;
    border: none;
    outline: none;
    font-weight: 500;
}

.btn-add-option {
    margin-top: 10px;
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-add-option:hover {
    background: #f8fafc;
    border-color: var(--accent);
    color: var(--accent);
}

.btn-remove-opt, .btn-remove-group {
    background: #fef2f2;
    color: #ef4444;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-remove-opt:hover, .btn-remove-group:hover {
    background: #ef4444;
    color: white;
}

.price-input-wrapper {
    width: 110px;
    display: flex;
    align-items: center;
    background: #f8fafc;
    border-radius: 8px;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
}

.price-input-wrapper span {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 4px;
    font-weight: 600;
}

.price-input-wrapper input {
    width: 100%;
    border: none;
    background: transparent;
    font-weight: 700;
    outline: none;
    font-size: 0.95rem;
}

/* --- HEADER DE INVENTARIO --- */
.inventory-header {
    margin-bottom: 32px;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: flex-end; /* Alineación a la derecha */
}

@media (max-width: 768px) {
    .header-actions { justify-content: flex-start; }
}

.header-filters {
    display: flex;
    gap: 10px;
    align-items: center;
}

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

#btn-new-product {
    width: auto; /* Anular el 100% global */
    white-space: nowrap;
    padding: 12px 24px;
    font-size: 0.95rem;
}

.custom-select {
    padding: 10px 15px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: white;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
}

.btn-icon-alt {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-alt i { width: 20px; height: 20px; }

.btn-icon-alt:hover {
    background: #f1f5f9;
    color: var(--accent);
    border-color: var(--accent);
}
/* --- SELECTORES PREMIUM (WRAPPERS) --- */
.filter-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 0 16px;
    height: 42px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.filter-wrapper:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.1);
}

.filter-wrapper i {
    width: 16px;
    height: 16px;
    color: var(--accent);
    margin-right: 8px;
    pointer-events: none;
}

.filter-wrapper select {
    border: none;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    padding-right: 20px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    height: 100%;
}

.filter-wrapper::after {
    content: '';
    position: absolute;
    right: 16px;
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    pointer-events: none;
    margin-top: -4px;
}
