/*
 * Estilos mejorados para el componente de Product Management
 * Moderno, responsivo y con una estructura más limpia.
 */

/* ================== Animaciones ================== */
@keyframes shimmer {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* ================== Contenedor principal ================== */
.product-management-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.product-management-container {
    background-color: #ffffff; /* Color de fondo simplificado */
    border-radius: 20px;
    width: 95%;
    max-width: 1400px;
    height: 90%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.5s ease-out; /* Animación de entrada para el contenedor */
}

/* ================== Encabezado ================== */
.product-management-header {
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, #0f172a, #334155); /* Gradiente más limpio */
    color: #ffffff;
    position: relative;
    overflow: hidden;
}

    .product-management-header::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
        animation: shimmer 3s infinite;
        pointer-events: none;
    }

.product-management-title {
    font-size: 28px;
    font-weight: bold;
    background: linear-gradient(135deg, #ffffff, #f1f5f9);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0;
    position: relative;
    z-index: 1;
}

.product-management-buttons {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.product-management-btn {
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

    .product-management-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    }

.product-management-btn--primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    font-weight: 700;
}

.product-management-btn--secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ================== Mensajes de estado ================== */
.product-management-message {
    padding: 14px 24px;
    margin: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.product-management-message--success {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border: 1px solid #34d399;
    color: #065f46;
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.1);
}

.product-management-message--error {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border: 1px solid #f87171;
    color: #dc2626;
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.1);
}

/* ================== Contenido principal y scrollbar ================== */
.product-management-content {
    flex: 1;
    overflow-y: auto; /* Usar overflow-y para ser más explícito */
    padding: 24px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
}

    .product-management-content::-webkit-scrollbar {
        width: 8px;
    }

    .product-management-content::-webkit-scrollbar-track {
        background: #f1f5f9;
    }

    .product-management-content::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }

        .product-management-content::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }

/* ================== Filtros ================== */
.filters-container {
    background-color: #ffffff;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Mejora de responsividad */
    gap: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    font-size: 13px;
    color: #374151;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #ffffff; /* Asegurar consistencia */
}

    .filter-input:focus,
    .filter-select:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }

/* ================== Grid de productos ================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* Grid más adaptable */
    gap: 20px;
}

.product-card {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
    background-color: #ffffff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
    animation: fadeIn 0.5s ease;
    display: flex;
    flex-direction: column; /* Organizar el contenido de la tarjeta */
}

    .product-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }

.product-card__badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: #f59e0b;
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
}

.product-card__title {
    font-size: 18px;
    font-weight: bold;
    color: #1f2937;
    line-height: 1.3;
    margin: 0 0 8px 0;
}

.product-card__description {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin: 0 0 16px 0;
    flex-grow: 1; /* Permite que la descripción ocupe el espacio disponible */
}

.product-card__meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 13px;
}

.product-card__meta-item {
    padding: 8px;
    background-color: #f3f4f6;
    border-radius: 8px;
}

.product-card__meta-label {
    color: #6b7280;
    display: block;
    margin-bottom: 2px;
}

.product-card__meta-value {
    font-weight: bold;
    color: #374151;
}

.product-card__actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
    margin-top: auto; /* Empuja las acciones a la parte inferior */
}

.product-card__btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s ease;
}

    .product-card__btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

.product-card__btn--edit {
    flex: 1;
    background-color: #3b82f6;
    color: #ffffff;
}

.product-card__btn--delete {
    background-color: #dc2626;
    color: #ffffff;
    padding: 12px 16px;
}

/* ================== Estados (Carga y vacío) ================== */
.loading-container,
.empty-state {
    text-align: center;
    padding: 60px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb; /* Añadir borde para consistencia */
    margin: 20px; /* Margen para separarlo del borde del contenedor */
}

.loading-spinner {
    font-size: 48px;
    margin-bottom: 16px;
    animation: spin 2s linear infinite;
    display: inline-block;
}

.loading-text {
    color: #6b7280;
    font-size: 16px;
}

.empty-state__icon {
    font-size: 64px;
    margin-bottom: 16px;
    display: block;
    color: #d1d5db; /* Color más neutro para el ícono */
}

.empty-state__title {
    color: #374151;
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: bold;
}

.empty-state__description {
    color: #6b7280;
    margin-bottom: 16px;
    font-size: 14px;
}

.empty-state__action {
    padding: 12px 24px;
    background-color: #6b7280;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

    .empty-state__action:hover {
        background-color: #4b5563;
        transform: translateY(-1px);
    }

/* ================== Formulario de producto ================== */
.product-form {
    max-width: 900px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb; /* Consistencia en los bordes */
    animation: fadeIn 0.4s ease-out; /* Animación de entrada para el formulario */
}

.product-form__title {
    font-size: 22px;
    font-weight: bold;
    color: #1f2937;
    text-align: center;
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Grid adaptable */
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #374151;
    font-size: 15px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 14px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
}

    .form-input:focus,
    .form-textarea:focus,
    .form-select:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* ================== Checkboxes ================== */
.checkbox-group {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
    padding: 16px;
    background-color: #f3f4f6;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    flex-wrap: wrap; /* Permitir que los checkboxes se envuelvan */
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
}

.checkbox-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ================== Botones del formulario ================== */
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 24px;
    border-top: 2px solid #e5e7eb;
}

.form-btn {
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

    .form-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

.form-btn--cancel {
    background-color: #6b7280;
    color: #ffffff;
}

.form-btn--submit {
    background-color: #059669;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
    font-weight: 700;
}

    .form-btn--submit:disabled {
        background-color: #9ca3af;
        cursor: not-allowed;
        box-shadow: none;
        opacity: 0.7; /* Indicador visual de deshabilitado */
    }

/* ================== Responsive Design ================== */
@media (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .product-management-modal {
        padding: 10px;
    }

    .product-management-container {
        width: 100%;
        height: 100%;
        border-radius: 0; /* Sin border-radius en pantallas muy pequeñas */
        box-shadow: none; /* Sin sombra para ocupar toda la pantalla */
    }

    .product-management-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px;
    }

    .product-management-title {
        font-size: 20px;
        text-align: center;
    }

    .product-management-buttons {
        flex-direction: column;
        width: 100%;
    }

    .products-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .product-card__actions {
        flex-direction: column;
    }

    .product-card__btn--edit {
        order: 1;
    }

    .product-card__btn--delete {
        order: 2;
    }

    .form-actions {
        flex-direction: column;
    }

    .filters-container {
        grid-template-columns: 1fr;
    }
}

/* ================== Utilidades y miscelánea ================== */
.icon-fixed {
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}
