/* =====================================================
   ESTILOS CSS - Sistema de Gestión de Activos - SIGA
   =====================================================
   
   Archivo de estilos CSS responsivo para SIGA.
   
   ESTRUCTURA:
   1. Variables CSS (colores, sombras)
   2. Reset global (margin, padding, box-sizing)
   3. Estilos generales (body, container)
   4. Componentes (header, tarjetas, alertas)
   5. Animaciones
   6. Responsive design (768px, 480px)
   7. Tabla de resultados
   
   TEMA: Colores corporativos (rojo oscuro #8b0000, oro #d4af37)
   DISEÑO: Gradientes modernos, animaciones suaves, responsive first
   ===================================================== */

/* =====================================================
   VARIABLES CSS (Custom Properties)
   ===================================================== */
:root {
    /* COLORES PRIMARIOS (Rojo Oscuro) */
    --primary-color: #8b0000;      /* Rojo oscuro (principal) */
    --primary-dark: #660000;       /* Rojo más oscuro (hover, botones activos) */
    --primary-light: #c41e3a;      /* Rojo más claro (degradados) */
    
    /* COLORES SECUNDARIOS (Oro) */
    --secondary-color: #d4af37;    /* Oro (acentos, detalles) */
    
    /* COLORES FUNCIONALES */
    --success-color: #10b981;      /* Verde (operaciones exitosas) */
    --danger-color: #ef4444;       /* Rojo (errores) */
    --warning-color: #f59e0b;      /* Naranja (advertencias) */
    
    /* COLORES NEUTROS */
    --background: #f5f5f5;         /* Gris claro (fondo de página) */
    --surface: #ffffff;            /* Blanco (tarjetas, contenedores) */
    --text-primary: #1a1a1a;       /* Gris oscuro (texto principal) */
    --text-secondary: #666666;     /* Gris medio (texto secundario) */
    --border-color: #dddddd;       /* Gris claro (bordes) */
    
    /* SOMBRAS (profundidad visual) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* =====================================================
   RESET GLOBAL
   ===================================================== */
* {
    margin: 0;        /* Eliminar márgenes por defecto */
    padding: 0;       /* Eliminar padding por defecto */
    box-sizing: border-box;  /* Incluir padding y border en width/height */
}

/* =====================================================
   ESTILOS DEL BODY Y CONTENEDOR PRINCIPAL
   ===================================================== */
body {
    /* Tipografía */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text-primary);
    
    /* Layout */
    min-height: 100vh;          /* Ocupar altura completa de viewport */
    display: flex;              /* Flexbox para centrado */
    align-items: center;        /* Centrar verticalmente */
    justify-content: center;    /* Centrar horizontalmente */
    padding: 10px;              /* Espaciado responsivo reducido */
    
    /* Fondo: Gradiente diagonal rojo a oro */
    background: linear-gradient(135deg, #8b0000 0%, #c41e3a 50%, #d4af37 100%);
}

.container {
    width: 100%;
    max-width: 1400px;          /* Ancho máximo aumentado para pantallas grandes */
    animation: fadeIn 0.5s ease-in;  /* Animación de entrada suave */
}

/* Animación: Fade In (desvanecimiento entrada) */
@keyframes fadeIn {
    from {
        opacity: 0;              /* Inicial: invisible */
        transform: translateY(-20px);  /* Inicial: 20px arriba */
    }
    to {
        opacity: 1;              /* Final: visible */
        transform: translateY(0);      /* Final: en posición */
    }
}

/* =====================================================
   ENCABEZADO
   ===================================================== */
.header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);  /* Sombra de texto para legibilidad */
}

.header p {
    font-size: 1.1rem;
    opacity: 0.95;  /* Ligeramente transparente para jerarquía */
}

/* =====================================================
   TARJETA DE BÚSQUEDA Y RESULTADOS
   ===================================================== */
.search-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 2.5rem 3rem;       /* Más padding lateral para mejor espaciado */
    box-shadow: var(--shadow-xl);  /* Sombra profunda */
    margin-bottom: 2rem;
}

/* Formulario de búsqueda: Flex para botón y input lado a lado */
.search-form {
    display: flex;
    gap: 1rem;              /* Espacio entre elementos */
    margin-bottom: 1rem;
}

/* Grupo de input con ícono integrado */
.input-group {
    flex: 1;                /* Ocupar espacio disponible */
    position: relative;     /* Para posicionar ícono absolutamente */
}

.input-group input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;  /* Padding con espacio para ícono izquierdo */
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;  /* Transición suave en cambios */
    outline: none;
    background: var(--background);
}

/* Estado focus: resaltar cuando está activo */
.input-group input:focus {
    border-color: var(--primary-color);  /* Cambiar color de borde */
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);  /* Aura alrededor */
    background: white;                               /* Fondo blanco */
}

/* Ícono dentro del input */
.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);  /* Centrar verticalmente */
    color: var(--text-secondary);
    font-size: 1.2rem;
}

/* =====================================================
   BOTONES
   ===================================================== */
.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;  /* Animación suave en interacciones */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;    /* Evitar quiebre de línea */
}

/* Botón primario: degradado rojo */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
}

/* Efectos hover: elevar botón */
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);  /* Presionado */
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* =====================================================
   ALERTAS (Éxito, Error, Advertencia)
   ===================================================== */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.3s ease;  /* Animación de entrada */
}

/* Animación: Slide Down (deslizar hacia abajo) */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Alerta de éxito: Verde */
.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Alerta de error: Rojo */
.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Alerta de advertencia: Naranja */
.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* =====================================================
   TARJETA DE RESULTADOS
   ===================================================== */
.result-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem 3rem;         /* Más padding lateral para que quepan todas las columnas */
    box-shadow: var(--shadow-xl);
    animation: fadeIn 0.5s ease;
}

/* Encabezado de resultados */
.result-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
}

/* Ícono de resultado: Cuadrado con gradiente */
.result-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8rem;
}

.result-title h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.result-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* =====================================================
   GRID DE RESULTADOS
   ===================================================== */
.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));  /* Grid responsivo */
    gap: 1.5rem;
}

.result-item {
    background: var(--background);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

/* Efecto hover: elevar tarjeta y cambiar borde */
.result-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.result-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;    /* MAYÚSCULAS */
    letter-spacing: 0.05em;       /* Espaciado entre letras */
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-value {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;  /* Romper palabras largas */
}

.result-value.empty {
    color: var(--text-secondary);
    font-style: italic;  /* Indicar campo vacío */
}

/* Elemento de resultado a full ancho */
.result-full {
    grid-column: 1 / -1;  /* Ocupar todas las columnas */
}

/* =====================================================
   SPINNER (Indicador de carga)
   ===================================================== */
.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* =====================================================
   UTILIDAD: Hidden (Ocultar elemento)
   ===================================================== */
.hidden {
    display: none;
}

/* =====================================================
   RESPONSIVE DESIGN
   ===================================================== */

/* Pantallas medianas (tablets) */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2rem;
    }

    .search-card {
        padding: 1.5rem;
    }

    /* Formulario en columna en dispositivos pequeños */
    .search-form {
        flex-direction: column;
    }

    .result-card {
        padding: 1.5rem;
    }

    /* Grid de resultados en una sola columna */
    .result-grid {
        grid-template-columns: 1fr;
    }
}

/* Pantallas pequeñas (móviles) */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header p {
        font-size: 0.95rem;
    }

    .search-card,
    .result-card {
        padding: 1rem;
    }
}

/* =====================================================
   TABLA DE RESULTADOS (Grid View)
   ===================================================== */

.table-responsive {
    overflow-x: auto;              /* Scroll horizontal en móviles */
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.results-table {
    width: 100%;
    border-collapse: collapse;     /* Bordes unidos */
    font-size: 0.95rem;
}

/* Celdas de tabla: padding y bordes */
.results-table th,
.results-table td {
    padding: 1rem 2rem;
    text-align: left;
    border-bottom: 1px solid #999;
    border-right: 1px solid #999;
}

/* Eliminar borde derecho de última celda */
.results-table th:last-child,
.results-table td:last-child {
    border-right: none;
}

/* Ancho mínimo para columnas */
.results-table th:nth-child(1),
.results-table td:nth-child(1) {
    min-width: 140px;  /* Patrimonial */
}

.results-table th:nth-child(2),
.results-table td:nth-child(2) {
    min-width: 140px;  /* Serie */
}

.results-table th:nth-child(3),
.results-table td:nth-child(3) {
    min-width: 250px;  /* Descripción */
}

.results-table th:nth-child(4),
.results-table td:nth-child(4) {
    min-width: 250px;  /* Características */
}

.results-table th:nth-child(5),
.results-table td:nth-child(5) {
    min-width: 200px;  /* Dependencia */
}

/* Encabezado de tabla: fondo gris */
.results-table th {
    background: #e5e7eb;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;  /* No romper encabezado */
}

.results-table tr:last-child td {
    border-bottom: none;
}

/* Fila hover: resaltar */
.results-table tr:hover {
    background-color: var(--background);
}

/* Botón pequeño en tabla */
.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 8px;
    border: none;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* =====================================================
   ESTILOS PARA BOTONES DE ACCIÓN
   ===================================================== */

/* Contenedor de acciones en resultados */
.result-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Botón secundario */
.btn-secondary {
    background: var(--secondary-color) !important;
    color: var(--text-primary) !important;
    font-weight: 600 !important;
}

.btn-secondary:hover {
    background: #c9a227 !important;
    transform: translateY(-2px) !important;
}

/* =====================================================
   ESTILOS PARA MODAL
   ===================================================== */

/* Overlay del modal (fondo oscuro) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

/* Contenido del modal */
.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

/* Animación: Slide Up */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Encabezado del modal */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

/* Botón de cierre del modal */
.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.modal-close:hover {
    transform: rotate(90deg);
}

/* Formulario en el modal */
.modal-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Grupos de formulario */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input {
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

.form-group input::placeholder {
    color: var(--text-secondary);
}

/* Botones del formulario */
.form-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.form-buttons button {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

/* Responsive: Modal en móvil */
@media (max-width: 768px) {
    .modal-content {
        max-width: 95%;
    }
    
    .form-buttons {
        flex-direction: column;
    }
    
    .form-buttons button {
        width: 100%;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-form {
        padding: 15px;
    }
}