/* Variables de Diseño Moderno y Profesional */
:root {
    --primary-color: #4A90E2; 
    --primary-light: #7ab8f0;
    --secondary-color: #5C6F7F; 
    --accent-color: #7ED321; 
    --danger-color: #D0021B; 

    --bg-primary: #F0F2F5; 
    --bg-card: #FFFFFF; 
    --text-dark: #333333; 
    --text-light: #666666; 

    /* Nuevas Sombras Suaves */
    --shadow-soft: 0 4px 10px rgba(0, 0, 0, 0.05); 
    --shadow-medium: 0 8px 20px rgba(0, 0, 0, 0.1); 
    --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.15); 
    
    --border-radius-soft: 12px; 
    --border-radius-button: 8px; 
    --transition-fast: 0.2s ease-in-out;
    --transition-medium: 0.3s ease-in-out;

    --font-sans: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
}

/* Base y Reset */
body {
    font-family: var(--font-sans);
    margin: 0;
    padding: 0;
    background-color: var(--bg-primary);
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Contenedor principal */
.container {
    width: 90%;
    max-width: 1400px;
    margin: 40px auto;
    padding: 20px;
}

/* NUEVO: Contenedor para hacer el formulario más angosto y centrado */
.narrow-form-container {
    max-width: 600px;
    margin: 0 auto;
}

/* Encabezado con Degradado Oscuro */
header {
    background: linear-gradient(135deg, #367ABF, var(--primary-color));
    color: white;
    padding: 30px 0;
    text-align: center;
    box-shadow: var(--shadow-medium);
    margin-bottom: 30px;
}

header h1 {
    margin: 0;
    font-size: 2.8em;
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* Estilos de las "Tarjetas" (Cards) con Sombra Suave */
.card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-soft);
    box-shadow: var(--shadow-soft);
    padding: 25px 30px;
    margin-bottom: 25px;
    transition: box-shadow var(--transition-medium);
}

.card:hover {
    box-shadow: var(--shadow-medium);
}

.card-header {
    font-size: 1.8em;
    font-weight: 500;
    color: var(--secondary-color);
    margin-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 15px;
}

/* Botones con Degradados y Sombra/Efecto 3D */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 25px;
    margin: 8px;
    border-radius: var(--border-radius-button);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
    gap: 8px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15); 
}

/* AJUSTE PARA BOTONES DE ACCIÓN MÁS PEQUEÑOS EN LA TABLA */
.table .btn {
    padding: 6px 8px;
    font-size: 0.8em;
    gap: 4px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); 
}

.btn-primary {
    background: linear-gradient(180deg, var(--primary-light), var(--primary-color));
    color: white;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
    background: linear-gradient(0deg, var(--primary-light), var(--primary-color));
}

.btn-secondary {
    background: linear-gradient(180deg, #8198ab, var(--secondary-color));
    color: white;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.btn-secondary:hover {
    background: linear-gradient(0deg, #8198ab, var(--secondary-color));
}

.btn-danger {
    background: linear-gradient(180deg, #E65567, var(--danger-color));
    color: white;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}

.btn-danger:hover {
    background: linear-gradient(0deg, #E65567, var(--danger-color));
}

/* Botón solo con icono (para "Limpiar") */
.btn-icon {
    padding: 12px; 
    width: 48px; 
    height: 48px;
    box-sizing: border-box; 
    flex-shrink: 0; 
    gap: 0; 
}


/* Formularios - Inputs y Selects */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.95em;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #D0D7DE;
    border-radius: var(--border-radius-button);
    box-sizing: border-box;
    font-size: 1em;
    color: var(--text-dark);
    background-color: var(--bg-card);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3); 
    outline: none;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* Controles de Búsqueda y Filtro */
.filter-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    align-items: stretch; 
}

.filter-controls .form-control {
    flex: 1;
    min-width: 150px;
}

.filter-controls .btn {
    margin: 0;
    padding-top: 12px;
    padding-bottom: 12px;
}

/* Tablas de Datos */
.table-responsive {
    /* ELIMINAR RESTRICCIONES DE SCROLL */
    overflow-x: unset;
    max-height: unset;
    overflow-y: unset;
    margin-top: 25px;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background-color: var(--bg-card);
    border-radius: var(--border-radius-soft);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    
    table-layout: fixed; 
}

/* Reducción de fuente y padding en celdas de datos */
.table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #EFF2F5;
    word-wrap: break-word;
    font-size: 0.9em; 
}

.table th {
    background-color: var(--secondary-color);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75em; /* REDUCCIÓN ADICIONAL DE FUENTE EN ENCABEZADOS */
    letter-spacing: 0.5px;
    padding: 8px 10px; /* Reducción de padding en encabezados */
    position: sticky; 
    top: 0; 
    z-index: 10;
    white-space: nowrap; 
}

/* --- AJUSTES PARA Abreviar Etiquetas --- */

/* Encabezado: Observación */
.table th:nth-child(8) {
    width: 150px;
    font-size: 0; 
}
.table th:nth-child(8)::after {
    content: "OBS."; /* Muestra OBS. en lugar de OBSERVACIÓN */
    font-size: 0.8em; 
}


/* Ajuste de ancho de columnas para optimizar espacio */
.table th:nth-child(1), .table td:nth-child(1) { width: 30px; } /* Handle */
.table th:nth-child(2), .table td:nth-child(2) { width: 80px; } /* Sistema */
.table th:nth-child(3), .table td:nth-child(3) { width: 100px; } /* Marca */
.table th:nth-child(4), .table td:nth-child(4) { width: 120px; } /* Modelo */
.table th:nth-child(5), .table td:nth-child(5) { width: 150px; } /* Dependencia */
.table th:nth-child(6), .table td:nth-child(6) { width: 100px; } /* Código */
.table th:nth-child(7), .table td:nth-child(7) { width: 70px; text-align: center; } /* Cantidad */
.table th:nth-child(9), .table td:nth-child(9) { width: 80px; } /* Acciones */


.table th:first-child {
    border-top-left-radius: var(--border-radius-soft);
}
.table th:last-child {
    border-top-right-radius: var(--border-radius-soft);
}

.table tr:nth-child(even) {
    background-color: #F8F9FB;
}

.table tr:hover {
    background-color: #EBF3FC;
    cursor: pointer;
}

.table td:last-child {
    white-space: nowrap;
}

/* --- ESTILOS DE DRAG-AND-DROP (SORTABLEJS) --- */

.drag-handle {
    width: 30px;
    text-align: center;
    vertical-align: middle;
    cursor: grab !important;
}

.sortable-ghost {
    opacity: 0.5;
    background-color: #cceeff !important; 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Mensajes de feedback */
.message {
    padding: 15px 20px;
    margin-top: 15px;
    border-radius: var(--border-radius-button);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-soft); 
}

.message-error {
    background-color: #FEE8E8;
    color: var(--danger-color);
    border: 1px solid #FDC3C3;
}

.message-success {
    background-color: #E8FEE8;
    color: var(--accent-color);
    border: 1px solid #C3FDC3;
}

/* --- CORRECCIONES RESPONSIVE --- */

@media screen and (max-width: 992px) {
    .container {
        width: 98%;
        margin: 20px auto;
        padding: 10px;
    }

    .table-responsive {
        overflow-x: auto;
    }
    
    .filter-controls {
        flex-direction: column; 
        gap: 10px;
    }
    
    .filter-controls .form-control {
        min-width: unset;
        width: 100%;
    }

    .filter-controls .btn,
    .filter-controls .btn-icon { 
        width: 100%; 
        margin: 0; 
    }
    
    /* Ocultar columnas menos importantes en tablet */
    .table th:nth-child(4), .table td:nth-child(4), /* Modelo */
    .table th:nth-child(5), .table td:nth-child(5) { /* Dependencia */
        display: none;
    }
    /* Ocultar la versión completa de Observación en responsive */
    .table th:nth-child(8) {
        display: table-cell; 
        font-size: 0; 
    }
    .table th:nth-child(8)::after {
        content: "OBS."; 
        font-size: 0.8em; 
    }
}

@media screen and (max-width: 576px) {
    
    .btn {
        display: block; 
        width: 100%; 
        margin: 5px 0; 
    }
    
    .container > .btn.btn-secondary { 
        display: inline-flex; 
        width: 100%;
        margin: 15px 0 25px 0; 
    }

    .filter-controls .btn,
    .filter-controls .btn-icon {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
    
    /* Ocultar más columnas en móvil */
    .table th:nth-child(3), .table td:nth-child(3) { /* Marca */
        display: none;
    }
}