/* Estilos para el panel de administración */

.admin-container {
    display: flex;
    min-height: 100vh;
    background: #f5f5f5;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.3s ease;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .menu-text {
    display: none;
}

.sidebar.collapsed .sidebar-header h3 {
    display: none;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px;
}

.sidebar-header .md-btn-icon {
    background: transparent;
    color: white;
    box-shadow: none;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-menu a.active {
    background: #4caf50;
    color: white;
}

.sidebar-menu .material-icons {
    font-size: 24px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 20px;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed + .main-content {
    margin-left: 60px;
}

.content-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    margin: 0;
    color: #2c3e50;
}

/* Table Styles */
.table-responsive {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: #34495e;
    color: white;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.data-table .badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge.activo {
    background: #d4edda;
    color: #155724;
}

.badge.inactivo {
    background: #f8d7da;
    color: #721c24;
}

.data-table .actions {
    display: flex;
    gap: 8px;
}

.data-table .btn-icon {
    padding: 6px;
    min-width: auto;
    border-radius: 50%;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-content.modal-large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #ecf0f1;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    color: #7f8c8d;
}

.modal-close:hover {
    color: #2c3e50;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #ecf0f1;
}

/* Filters */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filters select {
    min-width: 200px;
}

/* Precios Container */
#preciosContainer {
    display: block;
    margin-top: 10px;
}

.precios-derivados-nota {
    margin: 6px 0 10px;
    color: #666;
    font-size: 13px;
}

.precios-tabla-wrapper {
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    overflow-x: auto;
    background: #fff;
}

.precios-tabla-articulo {
    min-width: 760px;
}

.precios-tabla-articulo td {
    vertical-align: top;
}

.precios-tabla-articulo .md-input {
    width: 100%;
    min-width: 120px;
}

.precios-tabla-articulo .precio-tabla-derivada {
    background: #fafafa;
}

.precio-tabla-ayuda {
    margin-top: 6px;
    font-size: 12px;
    color: #666;
    line-height: 1.35;
}

.precio-tabla-nro {
    color: #777;
}

.precio-lista-chip-derivada {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fff3cd;
    color: #856404;
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}

/* ========================================
   MÓDULO IMPORTACIÓN XLS
   ======================================== */

.importacion-card {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 24px;
}

.drop-zone {
    border: 2px dashed #b0bec5;
    border-radius: 8px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    background: #fafafa;
    transition: border-color 0.2s ease, background 0.2s ease;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.drop-zone:hover {
    border-color: #4caf50;
    background: #f1f8e9;
}

.drop-zone.drag-over {
    border-color: #4caf50;
    background: #e8f5e9;
    transform: scale(1.01);
}

.drop-zone.file-selected {
    border-color: #2196f3;
    background: #e3f2fd;
}

.drop-zone-icon {
    font-size: 48px !important;
    color: #90a4ae;
}

.drop-zone.drag-over .drop-zone-icon,
.drop-zone:hover .drop-zone-icon {
    color: #4caf50;
}

.drop-zone.file-selected .drop-zone-icon {
    color: #2196f3;
}

.drop-zone-texto {
    color: #546e7a;
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
}

.drop-zone-texto small {
    color: #90a4ae;
    font-size: 13px;
}

.drop-zone-archivo {
    font-weight: 500;
    color: #1565c0;
    font-size: 14px;
    margin: 0;
    word-break: break-all;
}

.importacion-spinner {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #555;
    font-size: 14px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.spinning {
    animation: spin 1s linear infinite;
    display: inline-block;
    color: #4caf50;
}

.resumen-importacion-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.resumen-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-top: 4px solid #ccc;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.resumen-card .material-icons {
    font-size: 32px;
}

.resumen-valor {
    font-size: 36px;
    font-weight: 700;
}

.resumen-label {
    font-size: 13px;
    color: #666;
}

.resumen-total   { border-top-color: #607d8b; }
.resumen-total .material-icons, .resumen-total .resumen-valor { color: #607d8b; }

.resumen-creados { border-top-color: #4caf50; }
.resumen-creados .material-icons, .resumen-creados .resumen-valor { color: #4caf50; }

.resumen-actualizados { border-top-color: #2196f3; }
.resumen-actualizados .material-icons, .resumen-actualizados .resumen-valor { color: #2196f3; }

.resumen-errores { border-top-color: #f44336; }
.resumen-errores .material-icons, .resumen-errores .resumen-valor { color: #f44336; }

.resumen-tendencia {
    border-top-color: #9c27b0;
    cursor: pointer;
}

.resumen-tendencia .material-icons,
.resumen-tendencia .resumen-valor {
    color: #9c27b0;
}

.resumen-tendencia:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
}

.tendencia-mini-chart {
    width: 100%;
    max-width: 180px;
    height: 54px;
}

.tendencia-expandida-chart {
    width: 100%;
    height: 280px;
}

.tendencia-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.tendencia-grid {
    stroke: #e9edf3;
    stroke-width: 1;
}

.tendencia-line {
    fill: none;
    stroke: #9c27b0;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tendencia-area {
    fill: rgba(156, 39, 176, 0.12);
}

.tendencia-empty {
    color: #777;
    font-size: 13px;
    text-align: center;
    padding-top: 18px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .data-table {
        font-size: 14px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    #preciosContainer {
        grid-template-columns: 1fr;
    }

    .resumen-importacion-grid { grid-template-columns: repeat(2, 1fr); }
    .drop-zone { padding: 32px 16px; min-height: 120px; }
    .tendencia-expandida-chart { height: 220px; }
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .data-table .actions {
        flex-direction: column;
        gap: 5px;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #ecf0f1;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #95a5a6;
}

.empty-state .material-icons {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* ===== NUEVOS ESTILOS PARA FASE 3 ===== */

/* Árbol de Niveles/Categorías */
.tree-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    min-height: 300px;
}

.tree-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: 4px;
    background: #f8f9fa;
    transition: background 0.2s;
}

.tree-item:hover {
    background: #e9ecef;
}

.tree-item-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.tree-item-content .material-icons {
    color: #6c757d;
    font-size: 20px;
}

.tree-item-name {
    font-weight: 500;
    color: #343a40;
}

.tree-actions {
    display: flex;
    gap: 4px;
}

.tree-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.tree-actions button:hover {
    background: rgba(0, 0, 0, 0.1);
}

.tree-actions .material-icons {
    font-size: 18px;
}

.tree-item.level-0 {
    margin-left: 0;
    font-weight: 600;
}

.tree-item.level-1 {
    margin-left: 30px;
}

.tree-item.level-2 {
    margin-left: 60px;
}

.tree-item.level-3 {
    margin-left: 90px;
}

/* Preview de Imagen */
#previewImagenContainer {
    display: flex;
    align-items: center;
    gap: 12px;
}

#previewImagenContainer img {
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    object-fit: contain;
}

#previewImagenContainer button {
    align-self: flex-start;
}

.image-upload-hint {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
}

/* Badges para "Con IVA" / "Sin IVA" */
.badge-iva {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-con-iva {
    background: #d4edda;
    color: #155724;
}

.badge-sin-iva {
    background: #fff3cd;
    color: #856404;
}

/* Animación de carga (rotating) */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.rotating {
    animation: rotate 1s linear infinite;
    display: inline-block;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4caf50;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* Tabla de Historial de Precios */
.cambio-positivo {
    color: #28a745;
    font-weight: 600;
}

.cambio-negativo {
    color: #dc3545;
    font-weight: 600;
}

.cambio-neutral {
    color: #6c757d;
}

/* Sección de Actualización Masiva */
.tab-content {
    transition: all 0.3s ease;
}

.tab-content:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Botón de Exportar Excel */
.btn-exportar {
    color: #28a745 !important;
}

.btn-exportar:hover {
    background: rgba(40, 167, 69, 0.1);
}

/* Mejoras de accesibilidad */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Responsive para nuevas secciones */
@media (max-width: 768px) {
    .tree-item {
        padding: 8px 12px;
        font-size: 14px;
    }

    .tree-item.level-1 {
        margin-left: 20px;
    }

    .tree-item.level-2 {
        margin-left: 40px;
    }

    .tree-item.level-3 {
        margin-left: 60px;
    }

    #previewImagenContainer img {
        max-width: 100%;
        max-height: 200px;
    }

    .tab-content {
        padding: 15px !important;
    }

    .tab-content > div {
        grid-template-columns: 1fr !important;
    }

    .precios-tabla-wrapper {
        border: 0;
        background: transparent;
    }

    .precios-tabla-articulo {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .precios-tabla-articulo thead {
        display: none;
    }

    .precios-tabla-articulo tbody tr {
        display: grid;
        grid-template-columns: 1fr;
        background: #fff;
        border: 1px solid #e6e6e6;
        border-radius: 8px;
        padding: 10px;
    }

    .precios-tabla-articulo td {
        border: 0;
        padding: 6px 4px;
    }
}
